(function(){window["BXDEBUG"]=true;var t=window.BX,i={},e=200;t.namespace("BX.UI");if(t["UI"]["FileInput"])return;t["UI"]["FileInput"]=function(i,e,s,a,o){this.id=i;this.inited=false;this.uploadParams=e||{};this.uploadParams["urlUpload"]="/bitrix/tools/upload.php?lang="+t.message("LANGUAGE_ID");this.uploadParams["urlCloud"]="/bitrix/admin/clouds_file_search.php?lang="+t.message("LANGUAGE_ID")+"&n=";this.uploadParams["maxCount"]=parseInt(this.uploadParams["maxCount"])||0;this.onUploadDoneCounter=parseInt(this.uploadParams["maxIndex"]);if(this.onUploadDoneCounter>0)this.onUploadDoneCounter++;this.template=o;this.elementParams=s;this.menu=[];this.agent=null;this.container=null;this.frameFlags={hasNew:false,active:false,preparing:false,ready:false};this.framedItems=null;this.clickCloudPointBound=false;this.frameFilesWaitPopup=null;t.ready(t.proxy((function(){this.init(a)}),this))};t["UI"].FileInput.prototype={init:function(s){this.container=t(this.id+"_block");if(!this.container){setTimeout(t.proxy((function(){this.init(s)}),this),1e3);return}if(i[this.id]){if(i[this.id].container===this.container)return;i[this.id].destruct()}if(!this.container["fileInputIsAppended"]){this.container["fileInputIsAppended"]=0;this.container.appendChild(t.create("INPUT",{attrs:{className:"adm-fileinput-drag-area-input",type:"file",id:this.id+"_input",multiple:this.uploadParams["maxCount"]!==1,"data-fileinput":"Y"}}))}if(!t(this.id+"_input")){this.container["fileInputIsAppended"]++;if(this.container["fileInputIsAppended"]<100)setTimeout(t.proxy((function(){this.init(s)}),this),500);return}this.initFrameCounters();this.agent=t.Uploader.getInstance({id:this.id,streams:1,uploadMaxFilesize:this.uploadParams["uploadType"]==="file"?t.message("phpUploadMaxFilesize"):this.uploadParams["maxSize"],allowUpload:this.uploadParams["allowUpload"],allowUploadExt:this.uploadParams["allowUploadExt"],uploadFormData:"N",uploadMethod:"immediate",uploadFileUrl:this.uploadParams["urlUpload"],showImage:true,sortItems:this.uploadParams["allowSort"]==="Y",deleteFileOnServer:false,pasteFileHashInForm:false,input:t(this.id+"_input"),dropZone:t(this.id+"_block"),placeHolder:t(this.id+"_container"),thumb:{tagName:"DIV",className:"adm-fileinput-item-wrapper"},fields:{thumb:{tagName:"DIV",template:this.template},preview:{params:{width:e,height:e},events:{}}}});i[this.id]=this;this.fileEvents={onFileIsAttached:this.onFileIsAttached.bind(this),onFileIsAppended:this.onFileIsAppended.bind(this),onFileIsBound:this.onFileIsBound.bind(this),onFileIsReadyToFrame:this.onFileIsReadyToFrame.bind(this),onUploadProgress:this.onUploadProgress.bind(this),onUploadDone:this.onUploadDone.bind(this),onUploadError:this.onUploadError.bind(this),onUploadRestore:this.onUploadRestore.bind(this)};this.agentEvents={onAttachFiles:this.onAttachFiles.bind(this),onQueueIsChanged:this.onQueueIsChanged.bind(this),onFileIsCreated:this.onFileIsCreated.bind(this),onFileIsInited:this.onFileIsInited.bind(this),onFileIsReadyToFrame:this.onFileIsReadyToFrame.bind(this),onFilesPropsAreModified:this.onFilesPropsAreModified.bind(this),onFileIsFramed:this.onFileIsFramed.bind(this),onFilesAreFramed:this.onFilesAreFramed.bind(this),onBxDragStart:this.onFileIsDragged.bind(this),onError:this.onError.bind(this)};if(this.uploadParams["upload"]){var a=this.uploadParams["upload"];this.agentEvents["onPackageIsInitialized"]=function(t,i){t.post.data["signature"]=a;t.post.size+=("signature"+a).length;this.onUploadStart(i)}.bind(this)}for(n in this.agentEvents){if(this.agentEvents.hasOwnProperty(n)){t.addCustomEvent(this.agent,n,this.agentEvents[n])}}if(s.length>0){var o=[],h=[];this.values={};for(var n=0;n<s.length;n++){this.values[s[n]["id"]]=s[n];o.push(s[n]);h.push(t(s[n]["id"]+"Block"))}this.agent.onAttach(o,h,false)}this.initMenu(t(this.id+"_add"),this.uploadParams);this.checkUploadControl();t[this.elementParams["delete"]!==true?"addClass":"removeClass"](this.container,"adm-fileinput-non-delete");this.framedItems=new t.UploaderUtils.Hash;if(t(this.id+"ThumbModePreview")){t.bind(t(this.id+"ThumbModePreview"),"click",t.delegate((function(i){t.removeClass(t(this.id+"_mode"),"mode-file");t.removeClass(t(this.id+"_block"),"mode-file");t.addClass(t(this.id+"_mode"),"mode-pict");t.addClass(t(this.id+"_block"),"mode-pict");this.saveOptions("mode","mode-pict");return t.PreventDefault(i)}),this))}if(t(this.id+"ThumbModeNonPreview")){t.bind(t(this.id+"ThumbModeNonPreview"),"click",t.delegate((function(i){t.removeClass(t(this.id+"_mode"),"mode-pict");t.removeClass(t(this.id+"_block"),"mode-pict");t.addClass(t(this.id+"_mode"),"mode-file");t.addClass(t(this.id+"_block"),"mode-file");this.saveOptions("mode","mode-file");return t.PreventDefault(i)}),this))}this.inited=true},destruct:function(){var e;for(e in this.agentEvents){if(this.agentEvents.hasOwnProperty(e)){t.removeCustomEvent(this.agent,e,this.agentEvents[e])}}this.agent.destruct();this.deinitMenu(t(this.id+"_add"));t.remove(t(this.id+"_input"));delete this.noticeNode;delete this.nativeNoticeMessage;delete this.container;delete this.framedItems;t.unbindAll(t(this.id+"ThumbModePreview"));t.unbindAll(t(this.id+"ThumbModeNonPreview"));this.agent=null;delete this.agent;delete i[this.id]},checkUploadControl:function(){if(!this["noticeNode"]){this.noticeNode=t(this.id+"Notice");this.nativeNoticeMessage=t(this.id+"Notice").innerHTML}var i="adm-fileinput-drag-area "+"adm-fileinput-drag-area-error "+"adm-fileinput-drag-notification-count "+"adm-fileinput-drag-area-error-permission "+"adm-fileinput-drag-area-error-count";t.removeClass(this.container,i);if(!this.uploadParams["upload"]){this.noticeNode.innerHTML=t.message("JS_CORE_FI_UPLOAD_DENIED");t.addClass(this.container,"adm-fileinput-drag-area-error adm-fileinput-drag-area-error-permission")}else if(this.uploadParams["maxCount"]<=0||this.uploadParams["maxCount"]>this.agent.getItems().length){this.noticeNode.innerHTML=this.nativeNoticeMessage;t.addClass(this.container,"adm-fileinput-drag-area")}else if(this.uploadParams["maxCount"]===this.agent.getItems().length){this.noticeNode.innerHTML=t.message("JS_CORE_FI_TOO_MANY_FILES2");t.addClass(this.container,"adm-fileinput-drag-area adm-fileinput-drag-notification-count")}else{this.noticeNode.innerHTML=t.message("JS_CORE_FI_TOO_MANY_FILES3");t.addClass(this.container,"adm-fileinput-drag-area-error adm-fileinput-drag-area-error-count")}},saveOptions:function(i,e){t.userOptions.save("main","fileinput",i,e)},initMenu:function(i,e){i=t(i);if(!i||i.OPENER)return;this.initMenuCounter=(this.initMenuCounter||0)+1;var s,a=[];if(e["upload"]){s=this.id+"_menu"+this.initMenuCounter;a.push({ID:"upload",HTML:t.message("JS_CORE_FILE_UPLOAD")+'<input type="file" id="'+s+'"'+' class="adm-fileinput-area-input" />',GLOBAL_ICON:"adm-menu-upload-pc"})}if(e["medialib"]||e["fileDialog"]){a.push({TEXT:t.message("JS_CORE_FILE_INSERT_PATH"),ONCLICK:t.proxy(this.handlerFilePath,this),GLOBAL_ICON:"adm-menu-download"})}if(a.length>0){a.push({SEPARATOR:true})}if(e["medialib"]){a.push({TEXT:t.message("JS_CORE_FILE_MEDIALIB"),GLOBAL_ICON:"adm-menu-upload-medialib",ONCLICK:e["medialib"]["click"]+"()"});window[e["medialib"]["handler"]]=this.handlerMedialib.bind(this)}if(e["fileDialog"]){a.push({TEXT:t.message("JS_CORE_FILE_SITE"),GLOBAL_ICON:"adm-menu-upload-site",ONCLICK:e["fileDialog"]["click"]+"()"});window[e["fileDialog"]["handler"]]=this.handlerFileDialog.bind(this)}if(e["cloud"]){this.__cloudClick=this.clickCloudPoint.bind(this);a.push({TEXT:t.message("JS_CORE_FILE_CLOUD"),GLOBAL_ICON:"adm-menu-upload-cloud",ONCLICK:this.__cloudClick})}if(e["menu"]&&t.type.isArray(e["menu"])){a.push({SEPARATOR:true});for(var o=0;o<=e["menu"].length;o++){a.push(e["menu"])}a.push({SEPARATOR:true})}else if(e["medialib"]||e["fileDialog"]||e["cloud"]){a.push({SEPARATOR:true})}if(a.length>0&&this.agent.dialogName=="BX.Uploader"){a.push({GLOBAL_ICON:"adm-menu-crop",TEXT:t.message("JS_CORE_FI_FRAME_Y"),ONCLICK:this.frameFiles.bind(this),CHECKED:this.uploadParams["frameFiles"]=="Y"})}if(this.elementParams["edit"]&&this.elementParams["description"]!==false){a.push({TEXT:t.message("JS_CORE_FI_PIN_DESCRIPTION"),ONCLICK:this.pinDescription.bind(this),CHECKED:this.uploadParams["pinDescription"]=="Y"})}if(this.elementParams["delete"]){a.push({TEXT:t.message("JS_CORE_FI_CLEAR"),ONCLICK:this.deleteFiles.bind(this),GLOBAL_ICON:"adm-menu-delete"})}if(a.length>0){i.OPENER=new t.COpener({DIV:i,TYPE:"click",MENU:a,ACTIVE_CLASS:"adm-btn-active"});if(s){i.__onOpenerMenuOpen=t.delegate((function(){t.adjust(t(s).parentNode,{style:{position:"relative"}});this.agent.init(t(s));t.removeCustomEvent(i.OPENER,"onOpenerMenuOpen",i.__onOpenerMenuOpen)}),this);t.addCustomEvent(i.OPENER,"onOpenerMenuOpen",i.__onOpenerMenuOpen)}}},deinitMenu:function(i){i=t(i);if(!i||!i.OPENER)return;t.removeCustomEvent(i.OPENER,"onOpenerMenuOpen",i.__onOpenerMenuOpen);t.unbindAll(i.OPENER.DIV);delete i.OPENER.DIV;delete i.OPENER},handlerFilePathPopup:null,handlerFilePath:function(i){if(t.type.isArray(i)){var e=[];for(var a=0;a<i.length;a++){if(t.type.isNotEmptyString(i[a])){e.push({tmp_url:t.util.htmlspecialchars(i[a]),real_url:decodeURIComponent(i[a])})}}this.agent.onAttach(e)}else{this.handlerFilePathPopup=this.handlerFilePathPopup||new s(this.id+"filePath",{onApply:this.handlerFilePath.bind(this)},this.uploadParams["maxCount"]);this.handlerFilePathPopup.show()}},handlerMedialib:function(i){if(!t.type.isArray(i))i=[i];var e=[];for(var s=0;s<i.length;s++){if(i[s]){e.push({name:t.UploaderUtils.getFileNameOnly(i[s]["src"]),description:i[s]["description"],type:i[s]["type"]+"/medialib",size:i[s]["file_size"],sizeFormatted:i[s]["file_size"],tmp_url:i[s]["src"],real_url:i[s]["src"]})}}this.agent.onAttach(e,e)},handlerFileDialog:function(i,e){if(t.type.isNotEmptyString(i)&&t.type.isNotEmptyString(e)){var s={name:i,type:(t.UploaderUtils.isImageExt((i||"").lastIndexOf(".")>0?i.substr(i.lastIndexOf(".")+1):"")?"image":"notimage")+"/filedialog",tmp_url:e+"/"+i,real_url:e+"/"+i};this.agent.onAttach([s],[s])}},clickCloudPointPath:"/bitrix/admin/clouds_file_search.php?lang="+t.message("LANGUAGE_ID")+"&n=undefined",clickCloudPoint:function(){if(this.clickCloudPointBound===false){t.addCustomEvent("onCloudFileIsChosen",this.clickCloudPointChange.bind(this));this.clickCloudPointBound=true}t.util.popup(this.clickCloudPointPath,710,600)},clickCloudPointChange:function(i){var e=t.UploaderUtils.getFileNameOnly(i);if(t.type.isNotEmptyString(i)){var s={name:e,type:(t.UploaderUtils.isImageExt((e||"").lastIndexOf(".")>0?e.substr(e.lastIndexOf(".")+1):"")?"image":"notimage")+"/cloudfile",tmp_url:i};this.agent.onAttach([s],[s])}},frameFiles:function(i){if(i&&!t.type.isNumber(i)&&i["type"]=="click"){this.uploadParams["frameFiles"]=this.uploadParams["frameFiles"]=="Y"?"N":"Y";this.saveOptions("frameFiles",this.uploadParams["frameFiles"]);if(this.uploadParams["frameFiles"]=="N")return false}if(this.frameFlags.active===true&&(i||this.frameFlags.hasNew)){try{if(!this["__frameFiles"]){this["__frameFiles"]=t.delegate((function(){t.removeCustomEvent(this,"onFilesCanBeFramed",this.__frameFiles);if(this.frameFilesWaitPopup)this.frameFilesWaitPopup.close();this.framedItems=new t.UploaderUtils.Hash;if(!this.frameFilesBound){this.frameFilesBound=true;t.addCustomEvent(m,"onDeleteItem",t.delegate((function(t){this.deleteFile(t)}),this))}this.frameFlags.hasNew=false;var e=t.clone(this.uploadParams,true);e["description"]=this.elementParams["description"];m.start(this.agent,i||this.counters.newItemId,e);this["__frameFiles"]=null;delete this["__frameFiles"]}),this)}t.removeCustomEvent(this,"onFilesCanBeFramed",this["__frameFiles"]);if(this.frameFlags.ready===true){this.__frameFiles()}else{this.frameFilesWait();t.addCustomEvent(this,"onFilesCanBeFramed",this.__frameFiles)}}catch(t){console.log(t)}}return true},pinDescription:function(i){this.uploadParams["pinDescription"]=this.uploadParams["pinDescription"]=="Y"?"N":"Y";this.saveOptions("pinDescription",this.uploadParams["pinDescription"]);if(this.uploadParams["pinDescription"]=="Y"){if(!t.hasClass(t(this.id+"_block"),"mode-with-description"))t.addClass(t(this.id+"_block"),"mode-with-description")}else{t.removeClass(t(this.id+"_block"),"mode-with-description")}return t.PreventDefault(i)},frameFilesWait:function(){if(this.frameFilesWaitPopup==null){this.frameFilesWaitPopup=t.PopupWindowManager.create("popup-frame-wait"+this.id,null,{autoHide:true,titleBar:t.message("JS_CORE_LOADING"),contentColor:"white",closeIcon:true,closeByEsc:true,content:'<span class="adm-photoeditor-popup-frame-wait"><span></span>'+t.message("JS_CORE_FI_FRAME_IS_LOADING")+"</span>",overlay:{},events:{onPopupClose:t.proxy((function(){t.removeCustomEvent(this,"onFilesCanBeFramed",this.__frameFiles)}),this)},buttons:[new t.PopupWindowButtonLink({text:t.message("JS_CORE_WINDOW_CANCEL"),className:"popup-window-button-link-cancel",events:{click:t.delegate((function(){this.frameFilesWaitPopup.close()}),this)}})]})}this.frameFilesWaitPopup.show()},initFrameCounters:function(){this.counters={images:{created:new t.UploaderUtils.Hash,ready:new t.UploaderUtils.Hash},uploaded:new t.UploaderUtils.Hash,newItemOrder:0,newItemId:0}},incrementFrameCounter:function(t,i){if(i.dialogName=="BX.UploaderImage"){if(this.values&&this.values[i.id]){this.counters.uploaded.setItem(t,i.dialogName)}else if(!this.counters.uploaded.hasItem(t)||this.counters.uploaded.getItem(t)!==i.dialogName){if(this.frameFlags.hasNew!==true){this.frameFlags.hasNew=true;this.counters.newItemOrder=this.counters.images.created.length;this.counters.newItemId=t}}i.canvasIsReady=false;this.frameFlags.active=true;this.frameFlags.ready=false;this.counters.images.created.setItem(t,t)}},decrementFrameCounters:function(t,i){if(i.dialogName=="BX.UploaderImage"){this.counters.images.created.removeItem(t);this.counters.images.ready.removeItem(t);this.frameFlags.active=this.counters.images.created.length>0}},amountFrameCounter:function(i,e){if(e.dialogName=="BX.UploaderImage"){e.canvasIsReady=true;if(this.counters.uploaded.hasItem(i)){t.onCustomEvent(this.agent,"onFileIsReadyToFrame",[i,e])}}},onFileIsReadyToFrame:function(i,e){if(e.dialogName=="BX.UploaderImage"&&this.counters.images.created.hasItem(i)){this.counters.images.ready.setItem(i,i);this.frameFlags.ready=this.counters.images.created.length==this.counters.images.ready.length;if(this.frameFlags.ready){t.onCustomEvent(this,"onFilesCanBeFramed",[this])}}},deleteFiles:function(){var t=this.agent.getItems(),i;while((i=t.getFirst())&&i){this.deleteFile(i,true)}},onQueueIsChanged:function(){if(this.inited===true&&this.uploadParams["maxCount"]>0){this.checkUploadControl()}},onAttachFiles:function(i){var e=false;if(i&&this.inited===true&&this.uploadParams["maxCount"]>0){if(this.uploadParams["maxCount"]==1&&i.length>0){while(this.agent.getItems().length>0)this.deleteFile(this.agent.getItems().getFirst(),true);while(i.length>1)i.pop()}var s=this.uploadParams["maxCount"]-this.agent.getItems().length;s=s>0?s:0;while(i.length>s){i.pop();e=true}}if(e){this.onError(t.message("JS_CORE_FI_TOO_MANY_FILES").replace("#amount#",t.util.htmlspecialchars(this.uploadParams["maxCount"])),true)}return i},onFileIsCreated:function(i,e){if(this.inited===true)e.IND=this.onUploadDoneCounter++;if(e.file["preview_url"]&&e.file["width"]>0&&e.file["height"]>0){t.addCustomEvent(e,"onFileCanvasIsLoaded",t.proxy((function(){e.file["tmp_url"]=e.file["~tmp_url"];delete e.file["~tmp_url"];e.file["width"]=e.file["~width"];e.file["height"]=e.file["~height"];delete e.file["~width"];delete e.file["~height"];e.canvasIsLoaded=true;this.replaceHint(e)}),this));e.file["~tmp_url"]=e.file["tmp_url"];e.file["tmp_url"]=e.file["preview_url"];e.file["~width"]=e.file["width"];e.file["~height"]=e.file["height"];delete e.file["preview_url"]}else if(e.dialogName=="BX.UploaderImage"){t.addCustomEvent(e,"onFileCanvasIsLoaded",t.proxy((function(){e.canvasIsLoaded=true;this.replaceHint(e)}),this))}e.description=t.type.isNotEmptyString(e.file["description"])?e.file["description"]:"";this.incrementFrameCounter(i,e);for(var s in this["fileEvents"]){if(this["fileEvents"].hasOwnProperty(s)){if(this["fileEvents"][s]){t.addCustomEvent(e,s,this.fileEvents[s])}}}},onFileIsInited:function(t,i){this.amountFrameCounter(t,i)},onFileIsAppended:function(t,i){this.bindFile(i)},onFileIsBound:function(t,i){this.bindFile(i)},onFileIsAttached:function(t,i){if(i.file["sizeFormatted"]){i.size=i.file["sizeFormatted"];delete i.file["sizeFormatted"]}this.bindFile(i);if(i.file["tmp_url"])this.onUploadDone(i,{file:{uploadId:i.file.tmp_url}})},onFilesPropsAreModified:function(i,e,s){if(s){e.description=s.description;if(t(e.id+"Description"))t(e.id+"Description").value=e.description}},onFileIsFramed:function(i,e,s,a){if(s.width!=e.canvas.width||s.height!=e.canvas.height){t.adjust(e.canvas,{props:{width:s.width,height:s.height}})}else{t.adjust(e.canvas,{props:{width:e.canvas.width-1}});t.adjust(e.canvas,{props:{width:e.canvas.width+1}})}e.canvas.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,e.canvas.width,e.canvas.height);e.file=a;this.framedItems.setItem(e.id,e)},onFilesAreFramed:function(){if(this.framedItems&&this.framedItems.length>0){if(this.uploadParams["uploadType"]=="file"){}else{this.agent.restoreItems(this.framedItems,true,true);this.agent.submit()}}},onFileIsDragged:function(i,e){if(t.hasClass(t(this.id+"_block"),"mode-file")){t.addClass(e,"mode-file")}},onUploadStart:function(i){if(i.length>0){var e,s,a;for(a in i["items"]){if(i["items"].hasOwnProperty(a)){s=i["items"][a];e=(this.agent.getItem(s.id)||{node:false}).node;if(e&&!t.hasClass(e,"adm-fileinput-item-uploading"))t.addClass(e,"adm-fileinput-item-uploading")}}}},onUploadProgress:function(i,e){var s=this.agent.getItem(i.id).node;if(!s.hasAttribute("bx-progress-bound")){s.setAttribute("bx-progress-bound","Y");t.addClass(s,"adm-fileinput-item-uploading")}e=e<5?5:e>100?100:e;e=Math.ceil(e);if(t(i.id+"Progress",true)){t(i.id+"Progress",true).style.width=e+"%"}},onUploadDoneCounter:0,replaceInput:function(i,e){var s=this.agent.getItem(i.id).node,a=s["__replaceInputName"],o=i.id+"Value",h=t.findChild(s,{tagName:"INPUT",attr:{id:o}},true),n,r=e&&e["file"]&&e["file"]["files"]&&e["file"]["files"]["default"]?e["file"]["files"]["default"]:false;if(!a)a=s["__replaceInputName"]=h.name;if(r){h.parentNode.insertBefore(t.create("INPUT",{attrs:{type:"hidden",name:a+"[name]",id:h.id,value:i.name}}),h);h.parentNode.insertBefore(t.create("INPUT",{attrs:{type:"hidden",name:a+"[type]",value:r["type"]}}),h);h.parentNode.insertBefore(t.create("INPUT",{attrs:{type:"hidden",name:a+"[tmp_name]",value:r["path"]}}),h);h.parentNode.insertBefore(t.create("INPUT",{attrs:{type:"hidden",name:a+"[size]",value:r["size"]}}),h);h.parentNode.insertBefore(t.create("INPUT",{attrs:{type:"hidden",name:a+"[error]",value:0}}),h)}else{h.parentNode.insertBefore(t.create("INPUT",{attrs:{type:"hidden",name:a,id:h.id,value:e["file"]["uploadId"]}}),h)}while(t(h)&&h.name.indexOf(a)===0){n=h.nextSibling;t.remove(h);h=n}if(this.uploadParams["maxCount"]<=1){var l=t.findChild(this.container,{tagName:"INPUT",attr:{name:a}},false);if(l){t.adjust(l,{attrs:{disabled:true}});var p=a+"_del";if(a.indexOf("[")>0)p=a.substr(0,a.indexOf("["))+"_del"+a.substr(a.indexOf("["));l=t.findChild(this.container,{tagName:"INPUT",attr:{name:p}},false);if(l)t.adjust(l,{attrs:{disabled:true}})}}},onUploadDone:function(i,e){var s=this.agent.getItem(i.id),a=s.item,o=s.node;if(a&&t(o)){var h=e&&e["file"]&&e["file"]["files"]&&e["file"]["files"]["default"]?e["file"]["files"]["default"]:false;this.counters.uploaded.setItem(a.id,a.dialogName);if(h&&(h["wasChangedOnServer"]===true||a.dialogName=="BX.UploaderImage"!==t.UploaderUtils.isImage(h["name"],h["type"],h["size"]))){this.replaceItem(a,h,o)}else if(a.dialogName=="BX.UploaderImage"){this.amountFrameCounter(a.id,a)}this.replaceInput(a,e);if(o.firstChild&&t.hasClass(o.firstChild,"adm-fileinput-item-saved"))t.removeClass(o.firstChild,"adm-fileinput-item-saved");o.removeAttribute("bx-progress-bound");t.removeClass(o,"adm-fileinput-item-uploading");if(this.uploadParams["frameFiles"]=="Y")this.frameFiles()}},onUploadError:function(i,e){var s=this.agent.getItem(i.id).node;s.removeAttribute("bx-progress-bound");t.removeClass(s,"adm-fileinput-item-uploading adm-fileinput-item-image");t.addClass(s,"adm-fileinput-item-error");if(e&&e["error"]){s=t(i.id+"ErrorText");if(!s){s=t.create("SPAN",{attrs:{id:i.id+"ErrorText",className:"container-doc-error"}});t(i.id+"Name").parentNode.appendChild(s)}s.innerHTML=e["error"]}},onUploadRestore:function(){},onError:function(i,e){t.addClass(this.agent.placeHolder,"adm-fileinput-drag-area-error");if(e===true){alert(i)}else{t.debug(i)}},bindFile:function(i){var e=i.id,s=this.agent.getItem(i.id).node;if(i.dialogName=="BX.UploaderImage"){t.removeClass(s,"adm-fileinput-item-file");t.addClass(s,"adm-fileinput-item-image")}else{t.removeClass(s,"adm-fileinput-item-image");t.addClass(s,"adm-fileinput-item-file")}if(s&&!s.hasAttribute("bx-bound-editor")){s.setAttribute("bx-bound-editor","Y");if(this.agent.dialogName=="BX.UploaderSimple"){t.bind(s,"dblclick",t.delegate((function(e){var s=this.agent.getItem(i.id);if(s&&s.item.dialogName=="BX.UploaderImage"){var a=s.item.file["real_url"]||s.item.file["tmp_url"];if(a)t.util.popup(a)}return t.PreventDefault(e)}),this))}else if(this.elementParams["edit"]){t.bind(s,"dblclick",t.delegate((function(e){t.PreventDefault(e);var s=this.agent.getItem(i.id);if(s&&s.item.dialogName=="BX.UploaderImage"){this.frameFiles(i.id)}}),this))}}if(t(e+"Edit")&&!t(e+"Edit").hasAttribute("bx-bound")){t(e+"Edit").setAttribute("bx-bound","Y");if(this.elementParams["edit"]){t.bind(t(e+"Edit"),"click",t.delegate((function(e){t.PreventDefault(e);var s=this.agent.getItem(i.id);if(s&&s.item.dialogName=="BX.UploaderImage"){this.frameFiles(i.id)}}),this))}else{t.hide(t(e+"Edit"))}}if(t(e+"Del")&&!t(e+"Del").hasAttribute("bx-bound")){t(e+"Del").setAttribute("bx-bound","Y");t.bind(t(e+"Del"),"click",t.delegate((function(e){t.PreventDefault(e);this.deleteFile(i)}),this))}if(t(e+"Description")&&!t(e+"Description").hasAttribute("bx-bound")){t(e+"Description").setAttribute("bx-bound","Y");t.bind(t(e+"Description"),"click",t.delegate((function(i){t.defer_proxy((function(){t.focus(t(e+"Description"))}))();return t.PreventDefault(i)}),this));t.bind(t(e+"Description"),"blur",(function(){i.description=t(e+"Description").value}))}this.replaceHint(i)},replaceHint:function(i){var e=i.id,s=this.agent.getItem(i.id).node;if(s.hint)s.hint.Destroy();var a='<span class="adm-fileinput-drag-area-popup-title">'+t.util.htmlspecialchars(i.name)+"</span>";if(i.size)a+='<span class="adm-fileinput-drag-area-popup-param">'+t.message("JS_CORE_FILE_INFO_SIZE")+":&nbsp;<span>"+i.size+"</span></span>";if(i.dialogName=="BX.UploaderImage"){var o="";if(i.file["width"]>0&&i.file["height"]>0){o=i.file.width+"x"+i.file.height}else if(i.canvasIsLoaded&&i.canvas){o=i.canvas.width+"x"+i.canvas.height}if(o!="")a+='<span class="adm-fileinput-drag-area-popup-param">'+t.message("JS_CORE_FILE_INFO_DIM")+":&nbsp;<span>"+o+"</span></span>"}if(i.description==undefined)i.description=t(e+"Description")&&t(e+"Description").value?t(e+"Description").value:"";if(i.description){a+='<span class="adm-fileinput-drag-area-popup-param">'+t.message("JS_CORE_FILE_DESCRIPTION")+":&nbsp;<span>"+t.util.htmlspecialchars(String(i.description).replace(/\&quot\;/gi,'"'))+"</span></span>"}var h=i["file"]?i["file"]["real_url"]||i["file"]["tmp_url"]:"";if(h){h=t.util.htmlspecialchars(h);a+='<span class="adm-fileinput-drag-area-popup-param">'+t.message("JS_CORE_FILE_INFO_LINK")+':&nbsp;<span><a target="_blank" href="'+h.replace(/[%]/g,"%25")+'">'+h+"</a></span></span>"}s.hint=new t.CHint({parent:s,show_timeout:10,hide_timeout:200,dx:-10,preventHide:true,min_width:165,hint:a})},replaceItem:function(t,i,e){i["id"]=t["id"];t.replaced=true;this.deleteFile(t,true);e.removeAttribute("bx-bound-editor");this.agent.onAttach([i],[e])},deleteFile:function(i,e){var s=i?this.agent.getItem(i.id):false;if(!s)return;i=s.item;this.decrementFrameCounters(i.id,i);for(var a in this["fileEvents"]){if(this["fileEvents"].hasOwnProperty(a))t.removeCustomEvent(i,a,this["fileEvents"][a])}var o=s.node;if(o){if(o.hint)o.hint.Destroy();if(i.replaced!==true)t.addClass(o,"adm-fileinput-item-remove")}var h=i["file"]["input_name"]||o["__replaceInputName"],n=h+"_del";if(h&&h.indexOf("[")>0)n=h.substr(0,h.indexOf("["))+"_del"+h.substr(h.indexOf("["));if(i["file"]["input_name"]){o=t.create("INPUT",{props:{name:h,type:"hidden",value:i["file"]["input_value"]}});this.container.appendChild(o);o=t.create("INPUT",{props:{name:n,type:"hidden",value:"Y"}});this.agent.fileInput.parentNode.appendChild(o)}else{var r=t.findChild(this.container,{tagName:"INPUT",attr:{name:h,disabled:true}},false);if(r){t.adjust(r,{attrs:{disabled:false}});t.adjust(t.findChild(this.container,{tagName:"INPUT",attr:{name:n,disabled:true}},false),{attrs:{disabled:false}})}}if(e!==true)setTimeout((function(){i.deleteFile()}),500);else i.deleteFile()},destroy:function(){this.deleteFiles()}};t["UI"].FileInput.getInstance=function(t){return i[t]};var s=function(i,e,s){this.single=parseInt(s)===1;this.id=i;this.number=0;this.templateNode=['<div class="adm-fileinput-item-panel"',this.single?' style="display: none;"':"",">",'<span class="adm-fileinput-item-panel-btn adm-btn-del" id="#id#_#number#_del">&nbsp;</span>',"</div>",'<div class="adm-fileinput-urls-item">','<label for="#id#_#number#_path">',t.message("JS_CORE_FI_LINK"),"</label>",'<input id="#id#_#number#_path" type="text" value="" />',"</div>"].join("").replace(/#id#/gi,t.util.htmlspecialchars(this.id));var a=this.number++;this.number++;this.template=['<div class="adm-fileinput-urls-container" id="#id#_container">','<ol class="adm-fileinput-list adm-fileinput-urls" id="#id#_list">',"<li>",this.templateNode.replace(/#number#/gi,a+""),"</li>","</ol>",'<a href="#" id="#id#_add_point" class="adm-fileinput-item-add"',this.single?' style="display:none"':"",">",t.message("JS_CORE_FI_ADD_LINK"),"</a>",'<div style="clear:both;"></div>',"</div>"].join("").replace(/#id#/gi,t.util.htmlspecialchars(this.id));if(e){for(var o in e){if(e["hasOwnProperty"]&&e.hasOwnProperty(o)){t.addCustomEvent(this,o,e[o])}}}this._onAfterShow=this.onAfterShow.bind(this);this._onApply=this.onApply.bind(this);this._onCancel=this.onCancel.bind(this);this._addRow=this.addRow.bind(this);this._delRow=this.delRow.bind(this)};s.prototype={popup:null,number:0,addRow:function(i){t.PreventDefault(i);var e=t(this.id+"_list"),s=this.number++;if(e){e.appendChild(t.create("LI",{html:this.templateNode.replace(/#number#/gi,s+"")}));t.defer_proxy((function(){t.bind(t(this.id+"_"+s+"_del"),"click",this._delRow);this.bindFocus()}),this)()}return false},bindFocus:function(){var i=t(this.id+"_list");if(i&&!this.single){for(var e=0;e<this.number;e++){if(t(this.id+"_"+e+"_path")){t.unbind(t(this.id+"_"+e+"_path"),"focus",this._addRow)}}for(e=this.number;e>=0;e--){if(t(this.id+"_"+e+"_path")){t.bind(t(this.id+"_"+e+"_path"),"focus",this._addRow);break}}}},delRow:function(i){var e=i["currentTarget"]||i["target"];if(t(e)){var s=t.findParent(e,{tagName:"LI"});if(t(s)){var a=s==s.parentNode.lastChild;t.remove(s);if(a)this.bindFocus()}}},onApply:function(){var i=t(this.id+"_list"),e=[],s;if(i){for(var a=0;a<=this.number;a++){s=t(this.id+"_"+a+"_path")?t(this.id+"_"+a+"_path").value:"";if(s&&s.length>0)e.push(s)}}t.onCustomEvent(this,"onApply",[e,this]);this.onCancel()},onCancel:function(){this.popup.close();this.popup.destroy();this.popup=null;this.number=0},onAfterShow:function(){t.bind(t(this.id+"_add_point"),"click",this._addRow);for(var i=0;i<=this.number;i++){if(t(this.id+"_"+i+"_del")){t.bind(t(this.id+"_"+i+"_del"),"click",this._delRow)}}this.bindFocus();t.removeCustomEvent(this.popup,"onAfterPopupShow",this._onAfterShow)},show:function(){if(this.popup===null){var i=t.create("DIV",{attrs:{id:this.id+"Proper"},style:{display:"none"},html:this.template});this.popup=t.PopupWindowManager.create("popup"+this.id,null,{autoHide:true,lightShadow:true,closeIcon:false,closeByEsc:true,content:i,overlay:{},events:{onAfterPopupShow:this._onAfterShow},buttons:[new t.PopupWindowButton({text:t.message("JS_CORE_FI_ADD"),className:"popup-window-button-accept",events:{click:this._onApply}}),new t.PopupWindowButtonLink({text:t.message("JS_CORE_FI_CANCEL"),className:"popup-window-button-link-cancel",events:{click:this._onCancel}})]})}this.popup.show();this.popup.adjustPosition()}};var a=0,o=function(){var i=function(t){this.id="framePreset"+a++;this.onAfterShow=this.onAfterShow.bind(this);this.addRow=this.addRow.bind(this);this.delRow=this.delRow.bind(this);if(t){this.init(t)}};i.prototype={active:null,id:"framePreset0",values:[],valuesInner:[],popup:null,number:0,maxLength:10,getTemplateNode:function(){return["<li>",'<div class="adm-fileinput-item-panel">','<span class="adm-fileinput-item-panel-btn adm-btn-del" id="#classId##id#_del">&nbsp;</span>',"</div>",'<div class="adm-fileinput-presets-item">','<input class="adm-fileinput-presets-title" id="presets_#id#__title_" name="presets[#id#][title]" type="text" value="#title#" placeholder="',t.message("JS_CORE_FI_TITLE"),'" />','<input class="adm-fileinput-presets-width" name="presets[#id#][width]" type="text" value="#width#" placeholder="',t.message("JS_CORE_FI_WIDTH"),'" />','<input class="adm-fileinput-presets-hight" name="presets[#id#][height]" type="text" value="#height#" placeholder="',t.message("JS_CORE_FI_HEIGHT"),'" />',"</div>","</li>"].join("").replace(/#classId#/gi,t.util.htmlspecialchars(this.id))},getTemplate:function(){return['<div class="adm-fileinput-presets-container" id="#classId#_container">','<form id="#classId#_form">','<ol class="adm-fileinput-list adm-fileinput-presets" id="#classId#_list">',"#nodes#","</ol>","</form>",'<a href="#" id="#classId#_add_point" class="adm-fileinput-item-add">',t.message("JS_CORE_FI_ADD_PRESET"),"</a>",'<div style="clear:both;"></div>',"</div>"].join("")},init:function(i){this.values=[];this.length=0;if(t.type.isArray(i["presets"])){var e;for(var s=0;s<i["presets"].length;s++){e=this.values.length;this.values.push({id:e,title:i["presets"][s]["title"],width:i["presets"][s]["width"],height:i["presets"][s]["height"]})}this.length=this.values.length;this.setActive(i["presetActive"])}},setActive:function(t){t=parseInt(t);this.activeId=this.values[t]?t:0;this.active=this.values[this.activeId]||null},edit:function(i){var e=t.proxy_context,s="",a=this.values;for(var o=0;o<a.length;o++){s+=this.getTemplateNode().replace(/#id#/gi,t.util.htmlspecialchars(a[o]["id"])).replace(/#title#/gi,t.util.htmlspecialchars(a[o]["title"])).replace(/#width#/gi,t.util.htmlspecialchars(a[o]["width"])).replace(/#height#/gi,t.util.htmlspecialchars(a[o]["height"]))}if(this.values.length<this.maxLength&&i&&i["width"]&&i["height"]){s+=this.getTemplateNode().replace(/#id#/gi,t.util.htmlspecialchars(o)).replace(/#title#/gi,"").replace(/#width#/gi,t.util.htmlspecialchars(i["width"])).replace(/#height#/gi,t.util.htmlspecialchars(i["height"]))}if(!!this.popup)this.popup.close();var h=t.pos(e);this.popup=new t.PopupWindow("bx-preset-popup-"+e.id,e,{lightShadow:true,offsetTop:-3,className:"bxu-poster-popup",offsetLeft:Math.ceil(h.width/2),autoHide:true,closeByEsc:true,bindOptions:{position:"top"},overlay:false,events:{onAfterPopupShow:this.onAfterShow,onPopupClose:function(){this.destroy()},onPopupDestroy:t.proxy((function(){this.popup=null}),this)},buttons:[new t.PopupWindowButton({text:t.message("CANVAS_OK"),className:"popup-window-button-accept",events:{click:t.delegate((function(){var i=t.UploaderUtils.FormToArray(t(this.id+"_form"));this.onApply(i.data);this.popup.close()}),this)}}),new t.PopupWindowButtonLink({text:t.message("CANVAS_CANCEL"),className:"popup-window-button-link-cancel",events:{click:function(){this.popup.close()}.bind(this)}})],content:this.getTemplate().replace(/#classId#/gi,t.util.htmlspecialchars(this.id)).replace(/#nodes#/i,s)});this.popup.show();this.popup.setAngle({position:"bottom"});this.popup.bindOptions.forceBindPosition=true;this.popup.adjustPosition();t.focus(t("popupText"+e.id));this.popup.bindOptions.forceBindPosition=false},onAfterShow:function(){t.bind(t(this.id+"_add_point"),"click",this.addRow);var i,e=false;for(var s=0;s<this.length;s++){i=t(this.id+s+"_del");if(i){t.bind(i,"click",this.delRow);e=(e===false?0:e)+1}}if(e===false)this.addRow();this.checkAddButton();if(t("presets_"+s+"__title_"))t.focus(t("presets_"+s+"__title_"))},checkAddButton:function(){var i=t(this.id+"_list"),e=this.maxLength>i.childNodes.length;if(e)t.removeClass(t(this.id+"_add_point"),"disabled");else t.addClass(t(this.id+"_add_point"),"disabled");return e},addRow:function(i){t.PreventDefault(i);var e=t(this.id+"_list"),s;if(e&&this.checkAddButton()){s=this.length++;e.appendChild(t.create("LI",{html:this.getTemplateNode().replace(/^<li(.*?)>/gi,"").replace(/<\/li(.*?)>$/gi,"").replace(/#id#/gi,t.util.htmlspecialchars(s)).replace(/#title#/gi,"").replace(/#width#/gi,"").replace(/#height#/gi,"")}));t.defer_proxy((function(){t.bind(t(this.id+s+"_del"),"click",this.delRow)}),this)()}this.checkAddButton();return false},delRow:function(i){var e=t.proxy_context||i["currentTarget"]||i["target"];if(t(e)){var s=t.findParent(e,{tagName:"LI"});if(s){t.remove(s)}}this.checkAddButton()},onApply:function(i){this.values=[];if(i&&i["presets"]){i["presets"]=t.util.array_values(i["presets"]);for(var e,s=0;s<i["presets"].length;s++){if(i["presets"][s]&&i["presets"][s]["width"]>0&&i["presets"][s]["height"]>0){e=this.values.length;this.values.push({id:e,width:i["presets"][s]["width"],height:i["presets"][s]["height"],title:i["presets"][s]["title"]||i["presets"][s]["width"]+"x"+i["presets"][s]["height"]})}}}this.save();t.onCustomEvent(this,"onApply",[this.values,this])},savedLastTime:"",save:function(){var i="";i+="&p[0][c]=main&p[0][n]=fileinput";if(this.values.length>0){for(var e,s=0;s<this.values.length;s++){for(e in this.values[s]){if(this.values[s].hasOwnProperty(e)){if(e!="id")i+="&p[0][v][presets]["+s+"]["+e+"]="+t.util.urlencode(this.values[s][e])}}}}else{i+="&p[0][v][presets]="}if(this.savedLastTime!=i){t.ajax({method:"GET",dataType:"html",processData:false,cache:false,url:t.userOptions.path+i+"&sessid="+t.bitrix_sessid()})}},getActive:function(){this.activeId=this.values[this.activeId]?this.activeId:0;var t=this.values[this.activeId];if(t)t["id"]=this.activeId;return t||null}};return i}();var h,n,r=function(i){this.params=i;this.preset=h=h||new o(i);t.addCustomEvent(this.preset,"onApply",this.onPresetsApply.bind(this));this.id="FM";this.handlers={show:this.onShow.bind(this),afterShow:this.onAfterShow.bind(this),close:this.onClose.bind(this),cancel:this.onCancel.bind(this),apply:this.onApply.bind(this)}};r.prototype={id:"",canvas:null,description:null,agent:null,items:null,activeItem:null,popup:null,init:function(t){if(t){this.params=t;this.preset.init(t)}this.params=this.params||{};this.params["description"]=this.params["description"]!==false},start:function(i,e,s){this.init(s);this.agent=i;this.items=new t.UploaderUtils.Hash;n=n||new t.UploaderFileCnvConstr;var a=this.agent.getItems(),o,h;a.reset();while((o=a.getNext())&&o){if(o.dialogName=="BX.UploaderImage"){h=this.id+"_"+o.id;this.items.setItem(h,{id:h,item:o,canvas:o.canvas.cloneNode(true),file:null,props:{description:o.description}});if(e==o.id)e=h}}if(this.items.length>0){this.activeItem=this.items.hasItem(e)?this.items.getItem(e):this.items.getFirst();this.showEditor()}},finish:function(i){if(this.items!==null&&this.agent!==null){var e;this.items.reset();while((e=this.items.getNext())&&e){if(i&&e.props){t.onCustomEvent(this.agent,"onFilesPropsAreModified",[e.item.id,e.item,e.props])}if(i&&e.file){t.onCustomEvent(this.agent,"onFileIsFramed",[e.item.id,e.item,e.canvas,e.file])}t.remove(e.canvas);delete e.canvas;delete e.file;delete e.item;delete e.props}t.onCustomEvent(this.agent,"onFilesAreFramed",[])}this.agent=null;this.items=null;this.activeItem=null},onShow:function(){},bindThumbItem:function(i){var e=t(i.id+"EditorItemCanvas");e.parentNode.replaceChild(i.canvas,e);t.addClass(i.canvas,"adm-photoeditor-preview-panel-container-img");i.canvas.setAttribute("id",i.id+"EditorItemCanvas");var s=0,a=function(e){s++;if(e){if(s>1)t.adjust(i.canvas,{props:{width:i.item.canvas.width,height:i.item.canvas.height}});t.removeCustomEvent(i.item,"onFileIsInited",a)}i.canvas.getContext("2d").drawImage(i.item.canvas,0,0)};t.addCustomEvent(i.item,"onFileIsInited",a);a();t.removeClass(t(i.id+"EditorItem"),"adm-photoeditor-preview-panel-container-wait");t.bind(t(i.id+"EditorItem"),"click",t.proxy((function(){if(this.activeItem!==i){this.setActiveItem(i)}}),this));t.bind(t(i.id+"EditorItemDelete"),"click",t.proxy((function(e){t.PreventDefault(e);this.deleteItem(i)}),this))},deleteItem:function(i){if(this.activeItem==i){this.items.setPointer(i.id);var e=this.items.getNext();if(e)this.setActiveItem(e);else this.clearActiveItem()}t.remove(t(i.id+"EditorItem"));i=this.items.removeItem(i.id);t.onCustomEvent(this,"onDeleteItem",[i.item])},saveActiveItem:function(i){if(this.activeItem!==null){var s=this.activeItem,a=t.UploaderUtils.scaleImage(i,{width:e,height:e});if(a.destin.width!=s.canvas.width||a.destin.height!=s.canvas.height){t.adjust(s.canvas,{props:a.destin})}else{t.adjust(s.canvas,{props:{width:s.canvas.width-1}});t.adjust(s.canvas,{props:{width:s.canvas.width+1}})}s.canvas.getContext("2d").drawImage(i,0,0,i.width,i.height,0,0,s.canvas.width,s.canvas.height);var o=i.toDataURL(s.item.file.type,.75);s.file=t.UploaderUtils.dataURLToBlob(o);s.file.width=i.width;s.file.height=i.height}},saveActiveItemChanges:function(){if(this.activeItem!=null){this.activeItem.props.description=this.description.value;if(this.canvas.changed===true){t.onCustomEvent(this.canvas,"onChange",[this.canvas.getCanvas(),this.canvas])}}return null},clearActiveItem:function(){this.activeItem=this.saveActiveItemChanges();this.canvas.set(t.create("CANVAS"),{props:{width:100,height:100}});this.description.value=""},setActiveItem:function(i){if(this.activeItem!=i){t.onCustomEvent(this,"onActiveItemIsChanged",[i,this.activeItem]);t.onCustomEvent(this.canvas,"onCropHasToBeHidden",[]);t.onCustomEvent(this.canvas,"onActiveItemIsChanged",[]);if(this.activeItem!==null){t.removeClass(t(this.activeItem.id+"EditorItem"),"active")}this.saveActiveItemChanges()}if(!t.hasClass(t(i.id+"EditorItem"),"active")){t.addClass(t(i.id+"EditorItem"),"active")}this.activeItem=i;this.description.value=String(i.props.description).replace(/\&quot\;/gi,'"');var e=i.file||i.item.file;this.canvas.set(i.canvas,{props:{width:e.width,height:e.height}});if(i.canvas.width!=e.width||i.canvas.height!=e.height){i.__onload=t.proxy((function(e){if(this.activeItem==i){t.adjust(n.getCanvas(),{props:{width:e.width,height:e.height}});n.getContext().drawImage(e,0,0);this.canvas.set(n.getCanvas(),false);i.__onerror()}}),this);i.__onerror=t.proxy((function(){if(this.activeItem==i){i.__onload=null;delete i.__onload;i.__onerror=null;delete i.__onerror}}),this);t.defer_proxy((function(){n.push(e,i.__onload,i.__onerror)}))()}},onAfterShow:function(){try{this.bindTemplate()}catch(i){this["bindTemplateCounter"]=(this["bindTemplateCounter"]||0)+1;if(this["bindTemplateCounter"]<10){setTimeout(t.proxy(this.onAfterShow,this),500)}}var i;this.items.reset();while((i=this.items.getNext())&&i){this.bindThumbItem(i)}this.canvas.setCancelNode(this.id+"cancel");this.canvas.setMapCollapsed(this.id+"MapCollapsed");this.setActiveItem(this.activeItem);t.bind(t(this.id+"turn-l"),"click",t.proxy((function(){this.rotate(false)}),this.canvas));t.bind(t(this.id+"turn-r"),"click",t.proxy((function(){this.rotate(true)}),this.canvas));t.bind(t(this.id+"flip-v"),"click",t.proxy((function(){this.flip(false)}),this.canvas));t.bind(t(this.id+"flip-h"),"click",t.proxy((function(){this.flip(true)}),this.canvas));t.bind(t(this.id+"crop"),"click",t.proxy((function(){this.crop(t.proxy_context)}),this.canvas));t.bind(t(this.id+"grayscale"),"click",t.proxy((function(){this.blackAndWhite()}),this.canvas));t.bind(t(this.id+"sign"),"click",t.proxy((function(){this.poster(t.proxy_context)}),this.canvas));t.bind(t(this.id+"scaleIndicator"),"mousedown",t.proxy(this.canvas.scale,this.canvas));t.bind(t(this.id+"scaleWidthPlus"),"mousedown",t.proxy((function(){this.increaseScale("width",true)}),this));t.bind(t(this.id+"scaleWidthPlus"),"mouseup",t.proxy((function(){this.scaleChange("width",true)}),this));t.bind(t(this.id+"scaleWidth"),"focus",t.proxy((function(){this.startTraceScale("width")}),this));t.bind(t(this.id+"scaleWidth"),"blur",t.proxy((function(){this.stopTraceScale("width")}),this));t.bind(t(this.id+"scaleWidthMinus"),"mousedown",t.proxy((function(){this.increaseScale("width",false)}),this));t.bind(t(this.id+"scaleWidthMinus"),"mouseup",t.proxy((function(){this.scaleChange("width",false)}),this));t.bind(t(this.id+"scaleHeightPlus"),"mousedown",t.proxy((function(){this.increaseScale("height",true)}),this));t.bind(t(this.id+"scaleHeightPlus"),"mouseup",t.proxy((function(){this.scaleChange("height",true)}),this));t.bind(t(this.id+"scaleHeight"),"focus",t.proxy((function(){this.startTraceScale("height")}),this));t.bind(t(this.id+"scaleHeight"),"blur",t.proxy((function(){this.stopTraceScale("height")}),this));t.bind(t(this.id+"scaleHeightMinus"),"mousedown",t.proxy((function(){this.increaseScale("height",false)}),this));t.bind(t(this.id+"scaleHeightMinus"),"mouseup",t.proxy((function(){this.scaleChange("height",false)}),this));this.onPresetsApply();t.bind(t(this.id+"presetsValues"),"change",t.proxy((function(){this.preset.setActive(t.proxy_context.value)}),this));t.bind(t(this.id+"presetInsert"),"click",t.proxy((function(){t(this.id+"scaleChained").checked=true;var i=this.preset.getActive();if(i){this.canvas.scaleInit(t(this.id+"scaleIndicator"));this.canvas.cropInsert(i,t(this.id+"crop"))}}),this));t.bind(t(this.id+"presetEdit"),"click",t.proxy(this.preset.edit,this.preset));t.addCustomEvent(this.canvas,"onCropStart",function(){t.removeClass(t(this.id+"presetSave"),"disabled")}.bind(this));t.addCustomEvent(this.canvas,"onCropFinish",function(){t.addClass(t(this.id+"presetSave"),"disabled")}.bind(this));t.bind(t(this.id+"presetSave"),"click",t.proxy((function(){if(this.canvas.busy===true&&this.canvas.cropObj){this.preset.edit(this.canvas.cropObj.cropParams)}}),this));t.bind(t(this.id+"editorQueueUp"),"click",t.proxy(this.up,this));t.bind(t(this.id+"editorQueueDown"),"click",t.proxy(this.down,this))},onPresetsApply:function(){var i=t(this.id+"presetsValues");if(i){var e="",s=this.preset.getActive(),a;for(a=0;a<this.preset.values.length;a++){e+='<option value="'+a+'" bx-width="'+t.util.htmlspecialchars(this.preset.values[a]["width"])+'" bx-height="'+t.util.htmlspecialchars(this.preset.values[a]["height"])+'"'+(a==s["id"]?' selected="selected"':"")+">"+t.util.htmlspecialchars(h.values[a]["title"]+"("+this.preset.values[a]["width"]+"x"+this.preset.values[a]["height"])+")</option>"}i.innerHTML=e}},onApply:function(){this.saveActiveItemChanges();this.popup["onApplyFlag"]=true;this.popup.close()},onCancel:function(){this.popup.close()},onClose:function(){this.finish(this.popup["onApplyFlag"]===true);t.removeCustomEvent(this.popup,"onPopupShow",this.handlers.show);t.removeCustomEvent(this.popup,"onAfterPopupShow",this.handlers.afterShow);t.removeCustomEvent(this.popup,"onPopupClose",this.handlers.close);t.onCustomEvent(this.canvas,"onPopupClose",[]);this.popup.destroy();this.popup=null;this.slider=null},bindTemplate:function(){this.canvas=new p(this.id+"editorActive",{block:t(this.id+"editorActiveBlock"),canvas:t(this.id+"editorActiveImageCanvas"),canvasBlock:t(this.id+"editorActiveImageBlock")});t.addCustomEvent(this.canvas,"onChange",this.saveActiveItem.bind(this));t.addCustomEvent(this.canvas,"onSetCanvas",this.scaleChangeSize.bind(this));t.addCustomEvent(this.canvas,"onScaleCanvas",this.scaleChangeSize.bind(this));this.canvas.registerWheel(t(this.id+"editorActiveBlock"));this.description=t(this.id+"editorDescription")},getTemplate:function(){var i="";var e=['<div class="adm-photoeditor-preview-panel-container adm-photoeditor-preview-panel-container-wait" id="#id#EditorItem"> \t\t\t\t<div class="adm-photoeditor-preview-panel-container-sub"> \t\t\t\t\t<img src="',"/bitrix/images/1.gif",'" class="adm-photoeditor-preview-panel-container-space" /> \t\t\t\t\t<span id="#id#EditorItemCanvas"></span> \t\t\t\t\t<span id="#id#EditorItemDelete" class="adm-photoeditor-preview-panel-container-close">&nbsp;</span> \t\t\t\t</div> \t\t\t</div>'].join(""),s;this.items.reset();while((s=this.items.getNext())&&s){i+=e.replace(/#id#/gi,t.util.htmlspecialchars(s.id))}return['<div class="adm-photoeditor-container"> \t\t\t<div class="adm-photoeditor-buttons-panel"> \t\t\t<div class="adm-photoeditor-buttons-panel-save disabled" id="',this.id,"presetSave",'"><span>',t.message("JS_CORE_FI_SAVE_PRESET"),'</span></div> \t\t\t<div class="adm-photoeditor-buttons-panel-cancel disabled" id="',this.id,"cancel",'"><span>',t.message("JS_CORE_FI_CANCEL_PRESET"),'</span></div> \t\t\t<div class="adm-photoeditor-btn-wrap"> \t\t\t\t<span class="adm-photoeditor-btn adm-photoeditor-btn-turn-l" id="',this.id,"turn-l",'" title="',t.message("CANVAS_TURN_L"),'"> \t\t\t\t\t<span class="adm-photoeditor-btn-icon"></span> \t\t\t\t</span> \t\t\t\t<span class="adm-photoeditor-btn adm-photoeditor-btn-turn-r" id="',this.id,"turn-r",'"title="',t.message("CANVAS_TURN_R"),'"> \t\t\t\t\t<span class="adm-photoeditor-btn-icon"></span> \t\t\t\t</span> \t\t\t\t<span class="adm-photoeditor-btn adm-photoeditor-btn-flip-v" id="',this.id,"flip-v",'" title="',t.message("CANVAS_FLIP_V"),'"> \t\t\t\t\t<span class="adm-photoeditor-btn-icon"></span> \t\t\t\t</span> \t\t\t\t<span class="adm-photoeditor-btn adm-photoeditor-btn-flip-h" id="',this.id,"flip-h",'" title="',t.message("CANVAS_FLIP_H"),'"> \t\t\t\t\t<span class="adm-photoeditor-btn-icon"></span> \t\t\t\t</span> \t\t\t\t<span class="adm-photoeditor-btn adm-photoeditor-btn-crop" id="',this.id,"crop",'" title="',t.message("CANVAS_CROP"),'"> \t\t\t\t\t<span class="adm-photoeditor-btn-icon"></span> \t\t\t\t</span> \t\t\t\t<span class="adm-photoeditor-btn adm-photoeditor-btn-grayscale" id="',this.id,"grayscale",'" title="',t.message("CANVAS_GRAYSCALE"),'"> \t\t\t\t\t<span class="adm-photoeditor-btn-icon"></span> \t\t\t\t</span> \t\t\t\t<span class="adm-photoeditor-btn adm-photoeditor-btn-sign" id="',this.id,"sign",'" title="',t.message("CANVAS_SIGN"),'"> \t\t\t\t\t<span class="adm-photoeditor-btn-icon"></span> \t\t\t\t</span> \t\t\t</div> \t\t\t<div id="',this.id,'cropPresets"> \t\t\t\t<div class="adm-photoeditor-buttons-panel-cropping"> \t\t\t\t\t<span class="crop">',t.message("JS_CORE_FI_FRAMING"),'</span> \t\t\t\t\t<span class="adm-select-wrap"> \t\t\t\t\t\t<select class="adm-select" id="',this.id,'presetsValues"></select> \t\t\t\t\t\t</span> \t\t\t\t</div> \t\t\t\t<div class="adm-photoeditor-btn-wrap"> \t\t\t\t\t<span class="adm-photoeditor-btn adm-photoeditor-btn-cut" id="',this.id,'presetInsert" title="',t.message("JS_CORE_FI_USE_PRESET"),'"> \t\t\t\t\t\t<span class="adm-photoeditor-btn-icon"></span> \t\t\t\t\t</span> \t\t\t\t\t<span class="adm-photoeditor-btn adm-photoeditor-btn-edit" id="',this.id,'presetEdit" title="',t.message("JS_CORE_FI_EDIT_PRESET"),'"> \t\t\t\t\t\t<span class="adm-photoeditor-btn-icon"></span> \t\t\t\t\t</span> \t\t\t\t</div> \t\t\t\t<span class="adm-photoeditor-btn adm-photoeditor-btn-ph disabled" id="',this.id,'MapCollapsed"> \t\t\t\t\t<span class="adm-photoeditor-btn-icon"></span> \t\t\t\t</span> \t\t\t</div> \t\t</div> \t\t<div class="adm-photoeditor-sidebar"> \t\t\t<div class="adm-photoeditor-sidebar-options"> \t\t\t\t<span class="adm-photoeditor-sidebar-options-title">',t.message("JS_CORE_FI_WIDTH"),'</span> \t\t\t\t<span class="adm-photoeditor-plus" id="',this.id,'scaleWidthPlus">&nbsp;</span> \t\t\t\t<input type="number" value="0" id="',this.id,'scaleWidth" /> \t\t\t\t<span class="adm-photoeditor-minus" id="',this.id,'scaleWidthMinus">&nbsp;</span> \t\t\t</div> \t\t\t<div class="adm-photoeditor-sidebar-options"> \t\t\t\t<div class="sidebar-options-checkbox-container"> \t\t\t\t\t<input type="checkbox" value="Y" id="',this.id,'scaleChained" checked /> \t\t\t\t\t<label for="',this.id,'scaleChained"><span class="label-icon"></span></label> \t\t\t\t</div> \t\t\t</div> \t\t\t<div class="adm-photoeditor-sidebar-options"> \t\t\t\t<span class="adm-photoeditor-sidebar-options-title">',t.message("JS_CORE_FI_HEIGHT"),'</span> \t\t\t\t<span class="adm-photoeditor-plus" id="',this.id,'scaleHeightPlus">&nbsp;</span> \t\t\t\t<input type="number" value="0" id="',this.id,'scaleHeight" /> \t\t\t\t<span class="adm-photoeditor-minus" id="',this.id,'scaleHeightMinus">&nbsp;</span> \t\t\t</div> \t\t\t<div class="adm-photoeditor-sidebar-scale"> \t\t\t\t<span class="adm-photoeditor-sidebar-scale-value" style="top: 0">+100%</span> \t\t\t\t<span class="adm-photoeditor-sidebar-scale-value" style="top: 25%">+50%</span> \t\t\t\t<span class="adm-photoeditor-sidebar-scale-value" style="top: 50%">0%</span> \t\t\t\t<span class="adm-photoeditor-sidebar-scale-value" style="top: 75%">-50%</span> \t\t\t\t<span class="adm-photoeditor-sidebar-scale-value" style="top: 100%">-100%</span> \t\t\t\t<div class="adm-photoeditor-scale-indicator" style="top: 50%" id="',this.id,'scaleIndicator">0%</div> \t\t\t</div> \t\t</div> \t\t<div class="adm-photoeditor"> \t\t\t<div class="adm-photoeditor-preview-panel"> \t\t\t\t<span class="adm-photoeditor-preview-panel-arrow-top" id="',this.id,'editorQueueUp"></span> \t\t\t\t<div class="adm-photoeditor-preview-panel-previews" id="',this.id,'editorQueue"> \t\t\t\t\t<div class="adm-photoeditor-preview-panel-previews-inner" id="',this.id,'editorQueueInner">',i,'</div> \t\t\t\t</div> \t\t\t\t<span class="adm-photoeditor-preview-panel-arrow-bottom" id="',this.id,'editorQueueDown"></span> \t\t\t</div> \t\t\t<div class="adm-photoeditor-active-block-outer"> \t\t\t\t<div class="adm-photoeditor-active-block" id="',this.id,'editorActiveBlock"> \t\t\t\t\t<div class="adm-photoeditor-active-image-block" id="',this.id,'editorActiveImageBlockOuter"> \t\t\t\t\t\t<div class="adm-photoeditor-active-image" id="',this.id,'editorActiveImageBlock"> \t\t\t\t\t\t\t<div class="adm-photoeditor-crop" id="',this.id,'editorActiveCrop"></div> \t\t\t\t\t\t\t<canvas id="',this.id,'editorActiveImageCanvas"></canvas> \t\t\t\t\t\t</div> \t\t\t\t\t\t<div class="adm-photoeditor-active-cursor"></div> \t\t\t\t\t\t<div class="adm-photoeditor-active-move-cursor"></div> \t\t\t\t\t</div> \t\t\t\t</div> \t\t\t\t<div class="adm-photoeditor-desc"><input type="text" id="',this.id,'editorDescription" placeholder="',t.message("JS_CORE_FILE_DESCRIPTION"),'"></div> \t\t\t</div> \t\t</div> \t</div>'].join("").replace(/[\n\t]/gi,"").replace(/>\s</gi,"><")},showEditor:function(){if(!this.popup||this.popup===null){var i=t.create("DIV",{attrs:{id:this.id+"Proper",className:"bxu-edit-popup"},style:{display:"none"},html:this.getTemplate()});this.popup=t.PopupWindowManager.create("popup"+this.id,null,{className:"bxu-popup"+(this.params["description"]!==false?"":" bxu-popup-nondescription"),autoHide:true,lightShadow:true,closeIcon:false,closeByEsc:true,content:i,overlay:{},events:{onPopupShow:this.handlers.show,onAfterPopupShow:this.handlers.afterShow,onPopupClose:this.handlers.close},buttons:[new t.PopupWindowButton({text:t.message("JS_CORE_WINDOW_SAVE"),className:"popup-window-button-accept",events:{click:this.handlers.apply}}),new t.PopupWindowButtonLink({text:t.message("JS_CORE_WINDOW_CANCEL"),className:"popup-window-button-link-cancel",events:{click:this.handlers.cancel}})]})}this.popup.show();this.popup.adjustPosition()},slider:null,initSliderParams:function(){if(this.slider==null){this.slider={top:0,step:30,outer:t(this.id+"editorQueue"),outerPos:t.pos(t(this.id+"editorQueue")),inner:t(this.id+"editorQueueInner"),innerPos:t.pos(t(this.id+"editorQueueInner"))};this.slider.maxHeight=Math.min(this.slider.outerPos.height-this.slider.innerPos.height,0)}return this.slider},up:function(i){if(this.initSliderParams()){this.slider.top=Math.min(this.slider.top+this.slider.step,0);this.slider.inner.style.top=this.slider.top+"px"}return t.PreventDefault(i)},down:function(i){if(this.initSliderParams()){this.slider.top=Math.max(this.slider.maxHeight,this.slider.top-this.slider.step);this.slider.inner.style.top=this.slider.top+"px"}return t.PreventDefault(i)},lastProportion:{width:0,height:0,"~width":0,"~height":0,timeout:null},increaseScale:function(i,e){if(this.increaseScaleTimeout>0)clearTimeout(this.increaseScaleTimeout);i=i=="width"?"width":"height";var s=i=="width"?t(this.id+"scaleWidth"):t(this.id+"scaleHeight"),a=this,o=function(){if(e===false){s.value=++a.lastProportion[i]}else if(e===true){s.value=Math.max(--a.lastProportion[i],1)}a.lastProportion[i]=parseInt(s.value);a.increaseScaleTimeoutCounter++;a.increaseScaleTimeout=setTimeout(o,150-Math.min(100,a.increaseScaleTimeoutCounter*a.increaseScaleTimeoutCounter))};this.increaseScaleTimeoutCounter=0;this.increaseScaleTimeout=setTimeout(o,50)},startTraceScale:function(i){if(this.traceScaleTimeout>0)clearTimeout(this.traceScaleTimeout);this.traceScaleTimeout=this.traceScaleTimeout>0?this.traceScaleTimeout:0;i=i=="width"?"width":"height";var e=i=="width"?t(this.id+"scaleWidth"):t(this.id+"scaleHeight");if(this.lastProportion[i]===parseInt(e.value)){this.traceScaleTimeout++;if(this.traceScaleTimeout>5){this.traceScaleTimeout=0;this.scaleAdjust(i,null)}}else{this.traceScaleTimeout=0;this.lastProportion[i]=parseInt(e.value)}this.traceScaleTimeout=setTimeout(t.proxy((function(){this.startTraceScale(i)}),this),500)},stopTraceScale:function(t){if(this.traceScaleTimeout>0)clearTimeout(this.traceScaleTimeout);this.traceScaleTimeout=0;this.scaleAdjust(t,null)},scaleChange:function(i,e){if(this.increaseScaleTimeout>0)clearTimeout(this.increaseScaleTimeout);if(this.traceScaleTimeout>0)clearTimeout(this.traceScaleTimeout);if(this.lastProportion.timeout===null)this.lastProportion.timeout=setTimeout(t.proxy(this.scaleAdjust,this),500)},scaleAdjust:function(i){this.lastProportion.timeout=null;if(i>0){this.lastProportion["~width"]=this.lastProportion.width=i;this.canvas.scaleWidth(this.lastProportion.width,true,t(this.id+"scaleIndicator"))}else{if(this.lastProportion["~width"]!=this.lastProportion.width){this.lastProportion["~width"]=this.lastProportion.width;this.canvas.scaleWidth(this.lastProportion.width,this.scaleIsChained(),t(this.id+"scaleIndicator"))}if(this.lastProportion["~height"]!=this.lastProportion.height){this.lastProportion["~height"]=this.lastProportion.height;this.canvas.scaleHeight(this.lastProportion.height,this.scaleIsChained(),t(this.id+"scaleIndicator"))}}},scaleIsChained:function(){return!!t(this.id+"scaleChained").checked},scaleChained:function(){t(this.id+"scaleWidth").value=this.lastProportion.width},scaleChangeSize:function(i){this.lastProportion["~width"]=this.lastProportion.width=t(this.id+"scaleWidth").value=i.width||0;this.lastProportion["~height"]=this.lastProportion.height=t(this.id+"scaleHeight").value=i.height||0}};var l=function(t){this.depth=t};l.prototype={id:"CanvasStack",depth:3,stack:[],number:0,init:function(){var i;while((i=this.stack.shift())&&i){t.remove(i);i=null}this.stack=[];t.onCustomEvent(this,"onChange",[this.stack.length,this.stack])},add:function(i){this.number++;var e=t.create("CANVAS",{attrs:{id:this.id+this.number},props:{width:i.width,height:i.height},style:{display:"none"}});e.getContext("2d").drawImage(i,0,0);this.stack.push(e);while(this.stack.length>this.depth){e=this.stack.shift();t.remove(e);e=null}t.onCustomEvent(this,"onChange",[this.stack.length,this.stack])},restore:function(){var i=this.stack.pop();if(i){t.onCustomEvent(this,"onRestore",[i]);t.remove(i);t.onCustomEvent(this,"onChange",[this.stack.length,this.stack])}}};var p=function(i,e){this.block=e.block;this.block.pos=t.pos(this.block);this.canvas=e.canvas;this.ctx=this.canvas.getContext("2d");this.canvasBlock=e.canvasBlock;var s=t.UploaderUtils.scaleImage(this.block.pos,{width:this.mapSize,height:this.mapSize});this.canvasMap=new u(e.block,{width:s.destin.width,height:s.destin.height,scale:s.coeff});t.addCustomEvent(this.canvasMap,"onMapPointerIsMoved",this.move.bind(this));t.addCustomEvent(this.canvasMap,"onMapIsInitialised",function(){this.registerWheel(this.canvasMap.root)}.bind(this));this.id=i;t.bind(window,"resize",t.proxy(this.onResizeWindow,this));this.stack=new l(5);t.addCustomEvent(this.stack,"onChange",this.changeCancelNode.bind(this));t.addCustomEvent(this.stack,"onRestore",this.restore.bind(this));t.addCustomEvent(this,"onActiveItemIsChanged",t.delegate(this.stack.init,this.stack));t.addCustomEvent(this,"onPopupClose",t.delegate((function(){if(this.cropObj){this.cropObj.finish()}this.canvasMap.hide(false)}),this))};p.prototype={registerWheel:function(i){t.bind(i,this.onWheelEvent,this.onWheel.bind(this));if(this.onWheelEvent=="DOMMouseScroll")t.bind(i,"MozMousePixelScroll",this.onWheel.bind(this))},onWheelEvent:"onwheel"in document.createElement("div")?"wheel":document["onmousewheel"]!==undefined?"mousewheel":"DOMMouseScroll",onWheelMaxSpeed:50,onWheelLastEvent:0,onWheel:function(i){var e,s=(new Date).getTime();if(s-this.onWheelLastEvent<this.onWheelMaxSpeed)return t.PreventDefault(i);this.onWheelLastEvent=s;if(i["deltaY"]){e=i["deltaY"]}else if(this.onWheelEvent=="mousewheel"){e=-1/40*i.wheelDelta}else{e=i.detail}if(e!=undefined){this.zoom(e*-1,i)}return t.PreventDefault(i)},startScale:1,mapSize:300,onResizeWindow:function(){},setHack:{width:0,height:0},set:function(i,e){var s=e||{props:{width:i.width,height:i.height}},a=this.block.pos,o,h,n;if(this.setHack.width+""==s.props.width+""&&this.setHack.height+""==s.props.height+""){this.setHack.width--;t.adjust(this.canvas,{props:this.setHack})}this.setHack.width=s.props.width;this.setHack.height=s.props.height;t.adjust(this.canvas,s);h=o=Math.min(this.canvas.width>0?a["width"]/this.canvas.width:1,this.canvas.height>0?a["height"]/this.canvas.height:1);o=0<o&&o<1?o:1;n={top:Math.ceil((a["height"]-this.canvas.height*o)/2),left:Math.ceil((a["width"]-this.canvas.width*o)/2),width:this.canvas.width,height:this.canvas.height,transform:"translate3d(0, 0, 0) scale("+o+", "+o+")"};this.zoomCounter=0;this.canvas.startScale=o;this.canvas.maxVisibleScale=h;this.canvas.scale=o;this.canvas.pos={absoluteLeft:n.left+a.left,absoluteTop:n.top+a.top,absoluteWidth:a.width,absoluteHeight:a.height,startedWidth:Math.ceil(this.canvas.width*o),startedHeight:Math.ceil(this.canvas.height*o),left:n.left,top:n.top,shiftX:0,"~shiftX":0,shiftY:0,"~shiftY":0};this.canvas.visiblePart={left:0,"~left":0,top:0,"~top":0,"~width":i.width,width:i.width,"~height":i.height,height:i.height,leftGap:this.canvas.pos.left,topGap:this.canvas.pos.top,rightGap:this.canvas.pos.absoluteWidth-this.canvas.pos.startedWidth-this.canvas.pos.left,bottomGap:this.canvas.pos.absoluteHeight-this.canvas.pos.startedHeight-this.canvas.pos.top};for(var r in n){if(n.hasOwnProperty(r)){if(n[r]>0){n[r]=n[r]+"px"}}}t.adjust(t(this.canvasBlock),{style:n});this.ctx.drawImage(i,0,0,i.width,i.height,0,0,this.canvas.width,this.canvas.height);this.canvasMap.init(this.canvas,e?e.props:false);t.onCustomEvent(this,"onSetCanvas",[this.canvas,i]);this.changed=false},setMapCollapsed:function(t){if(this.canvasMap)this.canvasMap.registerCollapsedNode(t)},setCancelNode:function(i){this.cancelNode=t(i);if(!t.hasClass(this.cancelNode,"disabled"))t.addClass(this.cancelNode,"disabled");t.bind(this.cancelNode,"click",t.delegate(this.stack.restore,this.stack))},changeCancelNode:function(i){if(i)t.removeClass(this.cancelNode,"disabled");else if(!t.hasClass(this.cancelNode,"disabled"))t.addClass(this.cancelNode,"disabled")},restore:function(i){this.set(i,{props:{width:i.width,height:i.height}});t.onCustomEvent(this,"onCropHasToBeHidden",[])},cursor:{x:0,y:0},zoomEdge:2,zoomCounter:0,busy:false,zoom:function(i,e){if(this.busy!==false)return;var s=0;if(i>0&&this.zoomCounter<this.zoomEdge)s=.1;else if(i<0&&this.zoomCounter>0)s=-.1;if(s!==0){this.zoomCounter+=s;var a=this.canvas.startScale+this.zoomCounter;if(e){t.fixEventPageXY(e);this.cursor={x:Math.max(0,Math.min(e.pageX-this.canvas.pos.absoluteLeft,this.canvas.pos.absoluteWidth)),y:Math.max(0,Math.min(e.pageY-this.canvas.pos.absoluteTop,this.canvas.pos.absoluteHeight))}}this.zoomProcess(a)}},zoomProcess:function(t){this.zoomCanvas(t);if(this.canvas.scale>this.canvas.maxVisibleScale){this.canvasMap.show();this.canvasMap.zoom(this.canvas.visiblePart)}else{this.canvasMap.zoom(this.canvas.visiblePart);this.canvasMap.hide(true)}},zoomCanvas:function(i,e){if(e===true||i<=this.canvas.startScale){this.canvas.visiblePart={left:0,"~left":0,top:0,"~top":0,"~width":this.canvas.width,width:this.canvas.width,"~height":this.canvas.height,height:this.canvas.height,leftGap:this.canvas.pos.left,topGap:this.canvas.pos.top,rightGap:this.canvas.pos.absoluteWidth-this.canvas.pos.startedWidth-this.canvas.pos.left,bottomGap:this.canvas.pos.absoluteHeight-this.canvas.pos.startedHeight-this.canvas.pos.top};this.canvas.pos["~shiftX"]=0;this.canvas.pos["~shiftY"]=0;this.canvas.pos.shiftX=0;this.canvas.pos.shiftY=0;this.canvas.scale=this.canvas.startScale}else{var s=this.cursor.x,a=this.cursor.y,o=(-1*(this.canvas.pos["~shiftX"]||0)+s)/this.canvas.scale,h=(-1*(this.canvas.pos["~shiftY"]||0)+a)/this.canvas.scale,n=o*i,r=h*i,l=Math.max(n-s,0),p=Math.max(r-a,0);this.formVisiblePart(i,l,p);l*=-1;p*=-1;this.canvas.pos["~shiftX"]=l;this.canvas.pos["~shiftY"]=p;this.canvas.pos.shiftX=Math.ceil(l);this.canvas.pos.shiftY=Math.ceil(p);this.canvas.scale=i}this.canvasBlock.style.transform="translate3d("+this.canvas.pos.shiftX+"px, "+this.canvas.pos.shiftY+"px, 0) "+"scale("+this.canvas.scale+", "+this.canvas.scale+")";t.onCustomEvent(this,"onCanvasPositionHasChanged",[])},formVisiblePart:function(t,i,e){var s=i-this.canvas.pos.left,a=e-this.canvas.pos.top;this.canvas.visiblePart["~left"]=(s>0?s:0)/t;this.canvas.visiblePart["left"]=Math.ceil(this.canvas.visiblePart["~left"]);this.canvas.visiblePart["~top"]=(a>0?a:0)/t;this.canvas.visiblePart["top"]=Math.ceil(this.canvas.visiblePart["~top"]);var o=this.canvas.width*t,h=-1*s,n=this.canvas.pos.absoluteWidth-(o+h);if(this.canvas.pos.absoluteWidth>o){if(h<0)o+=h;else if(n<0)o+=n}else{o=this.canvas.pos.absoluteWidth;if(h>0)o-=h;else if(n>0)o-=n}this.canvas.visiblePart["leftGap"]=h;this.canvas.visiblePart["rightGap"]=n;this.canvas.visiblePart["~etalonWidth"]=this.canvas.pos.absoluteWidth/t;this.canvas.visiblePart["~width"]=o/t;this.canvas.visiblePart["width"]=Math.ceil(this.canvas.visiblePart["~width"]);var r=this.canvas.height*t,l=-1*a,p=this.canvas.pos.absoluteHeight-(r+l);if(this.canvas.pos.absoluteHeight>r){if(l<0)r+=l;else if(p<0)r+=p}else{r=this.canvas.pos.absoluteHeight;if(l>0)r-=l;else if(p>0)r-=p}this.canvas.visiblePart["topGap"]=l;this.canvas.visiblePart["bottomGap"]=p;this.canvas.visiblePart["~etalonHeight"]=this.canvas.pos.absoluteHeight/t;this.canvas.visiblePart["~height"]=r/t;this.canvas.visiblePart["height"]=Math.ceil(this.canvas.visiblePart["~height"])},move:function(i){var e=Math.round(this.canvas.width*this.canvas.scale),s=Math.round(this.canvas.height*this.canvas.scale),a=-1*Math.ceil(i["left"]*this.canvas.scale),o=-1*Math.ceil(i["top"]*this.canvas.scale);if(i.right===true||e+a<this.canvas.pos.absoluteWidth)a=this.canvas.pos.absoluteWidth-e;if(i.bottom===true||s+o<this.canvas.pos.absoluteHeight)o=this.canvas.pos.absoluteHeight-s;a-=this.canvas.pos.left;o-=this.canvas.pos.top;this.formVisiblePart(this.canvas.scale,-1*a,-1*o);this.canvas.pos["~shiftX"]=a;this.canvas.pos["~shiftY"]=o;this.canvas.pos.shiftX=a;this.canvas.pos.shiftY=o;this.canvasBlock.style.transform="translate3d("+this.canvas.pos.shiftX+"px, "+this.canvas.pos.shiftY+"px, 0) "+"scale("+this.canvas.scale+", "+this.canvas.scale+")";t.onCustomEvent(this,"onCanvasPositionHasChanged",[])},canvasesID:"canvasForEdit",copyCanvas:null,workCanvas:null,getCopyCanvas:function(){if(this.copyCanvas===null){this.copyCanvas=t.create("CANVAS",{attrs:{id:this.id+"Copy"},style:{display:"none"}})}t.adjust(this.copyCanvas,{props:{width:this.canvas.width,height:this.canvas.height}});this.copyCanvas.getContext("2d").drawImage(this.canvas,0,0);return this.copyCanvas},getCanvas:function(){return this.canvas},getWorkCanvas:function(i){if(this.workCanvas===null){this.workCanvas=t.create("CANVAS",{attrs:{id:this.id+"Work"},style:{display:"none"}})}t.adjust(this.workCanvas,{props:{width:this.canvas.width,height:this.canvas.height}});if(i)this.workCanvas.getContext("2d").drawImage(this.canvas,0,0);return this.workCanvas},rotate:function(i){if(this.busy===true)return;var e=Math.PI/2*(i?1:-1),s=this.getCopyCanvas(),a=this.getWorkCanvas(false),o=this.canvas.height,h=this.canvas.width;t.adjust(a,{props:{width:o,height:h}});var n=a.getContext("2d");n.save();if(i)n.translate(s.height,0);else n.translate(0,s.width);n.rotate(e);n.drawImage(s,0,0);n.restore();this.set(a,{props:{width:o,height:h}});this.stack.add(s);this.changed=true},poster:function(i){if(this.busy===true)return;if(!!this.posterPopup)this.posterPopup.close();var e=t.pos(i);this.posterPopup=new t.PopupWindow("bx-poster-popup-"+i.id,i,{lightShadow:true,offsetTop:-3,className:"bxu-poster-popup",offsetLeft:Math.ceil(e.width/2),autoHide:true,closeByEsc:true,bindOptions:{position:"top"},overlay:false,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:t.proxy((function(){this.posterPopup=null}),this)},buttons:[new t.PopupWindowButton({text:t.message("CANVAS_OK"),events:{click:t.delegate((function(){var e=t("posterPopupText"+i.id);if(!!e&&e.value.length>0)this.posterApply(e.value);this.posterPopup.close()}),this)}}),new t.PopupWindowButtonLink({text:t.message("CANVAS_CANCEL"),events:{click:function(){this.posterPopup.close()}.bind(this)}})],content:['<div class="bxu-poster-popup-dt">',t.message("CANVAS_POSTER_SIGN"),'</div> \t\t\t\t<input type="text" id="posterPopupText',i.id,'" maxlength="255" value="" />'].join("")});this.posterPopup.show();this.posterPopup.setAngle({position:"bottom"});this.posterPopup.bindOptions.forceBindPosition=true;this.posterPopup.adjustPosition();t.focus(t("posterPopupText"+i.id));this.posterPopup.bindOptions.forceBindPosition=false},posterApply:function(t){if(t){this.stack.add(this.getCopyCanvas());var i=this.getWorkCanvas(true),e=i.getContext("2d"),s=Math.min(i.width,i.height)/10;e.fillStyle="black";e.fillRect(0,0,i.width,s);e.fillRect(0,i.height-2*s,i.width,2*s);e.fillRect(0,0,s,i.height);e.fillRect(i.width-s,0,s,i.height);e.strokeStyle="white";var a=5;e.strokeRect(s-a,s-a,i.width-s*2+2*a,i.height-s*3+2*a);e.fillStyle="white";e.textAlign="center";e.textBaseline="middle";e.font=s+"px marketing";e.fillText(t,i.width/2,i.height-s,i.width);this.set(i,false);this.changed=true}},blackAndWhite:function(){if(this.busy===true)return;this.stack.add(this.getCopyCanvas());var t=this.getWorkCanvas(true),i=t.getContext("2d"),e=i.getImageData(0,0,t.width,t.height),s,a;for(a=0;a<e.data.length;a+=4){s=(e.data[a]+e.data[a+1]+e.data[a+2])/3;e.data[a]=s;e.data[a+1]=s;e.data[a+2]=s}i.putImageData(e,0,0);this.set(t,false);this.changed=true},flip:function(t){if(this.busy===true)return;this.stack.add(this.getCopyCanvas());var i=this.getWorkCanvas(true),e=i.getContext("2d");e.save();if(t){e.scale(1,-1);e.translate(0,-i.height)}else{e.scale(-1,1);e.translate(-i.width,0)}e.drawImage(i,0,0);e.restore();this.set(i,false);this.changed=true},cropObj:null,cropStatus:false,cropInit:function(i){if(this.cropObj===null){this.cropObj=new c(this.id,this.canvas,t(this.id+"Crop"));this.cropObj.cropParams.topShift=parseInt(this.canvasBlock.style.top?this.canvasBlock.style.top.replace(/[a-z]+$/,""):0);this.cropObj.cropParams.leftShift=parseInt(this.canvasBlock.style.left?this.canvasBlock.style.left.replace(/[a-z]+$/,""):0);t.addCustomEvent(this,"onCropHasToBeHidden",t.delegate(this.cropObj.finish,this.cropObj));t.addCustomEvent(this.cropObj,"onCropApply",this.cropApply.bind(this));t.addCustomEvent(this.cropObj,"onCropTooBig",this.onCropTooBig.bind(this));t.addCustomEvent(this.cropObj,"onCropStart",t.delegate((function(){t.addClass(i,"bxu-edit-btn-active");this.cropStatus=true;this.busy=true;this.canvasMap.occupy();t.onCustomEvent(this,"onCropStart",[this.cropObj,this.cropObj.cropParams])}),this));t.addCustomEvent(this.cropObj,"onCropFinish",t.delegate((function(){t.removeClass(i,"bxu-edit-btn-active");this.busy=false;this.cropStatus=false;this.canvasMap.release();t.onCustomEvent(this,"onCropFinish",[this.cropObj,this.cropObj.cropParams])}),this));t.addCustomEvent(this,"onCanvasPositionHasChanged",t.delegate(this.cropObj.scale,this.cropObj))}return true},crop:function(t){if(this.cropInit(t))this.cropObj.turn()},onCropTooBigPopup:null,onCropTooBig:function(i,e){if(this.onCropTooBigPopup===null){this.onCropTooBigPopupApply=t.delegate((function(){var i=t.UploaderUtils.scaleImage(this.canvas,this.onCropTooBigPopup.presetParams,"circumscribed");if(i.bNeedCreatePicture){this.scaleZoom=false;this.scaleWidth(i.destin.width,true,t(this.id+"scaleIndicator"));this.scaleZoom=true}this.cropInsert(this.onCropTooBigPopup.presetParams);this.onCropTooBigPopup.close()}),this);this.onCropTooBigPopupCancel=t.delegate((function(){this.onCropTooBigPopup.close()}),this);this.onCropTooBigPopup=new t.PopupWindow("popupCropTooBigPopup"+this.id,null,{lightShadow:true,autoHide:true,closeByEsc:true,overlay:{},buttons:[new t.PopupWindowButton({text:t.message("JS_CORE_FI_SCALE"),className:"popup-window-button-accept",events:{click:this.onCropTooBigPopupApply}}),new t.PopupWindowButtonLink({text:t.message("JS_CORE_FI_CANCEL"),className:"popup-window-button-link-cancel",events:{click:this.onCropTooBigPopupCancel}})],content:'<div class="adm-photoeditor-buttons-panel-cropping-too-big">'+t.message("JS_CORE_FI_PRESET_IS_TOO_BIG")+"</div>"})}this.onCropTooBigPopup.presetParams={width:i,height:e};this.onCropTooBigPopup.show()},cropApply:function(i){this.stack.add(this.getCopyCanvas());var e=this.getWorkCanvas(false);t.adjust(e,{props:{width:i.width,height:i.height}});e.getContext("2d").drawImage(this.canvas,-1*i.left,-1*i.top);this.set(e,{props:{width:i.width,height:i.height}});this.changed=true},cropInsert:function(t,i){if(t&&this.cropInit(i)){this.cropObj.insert(t.width,t.height)}},scaleObj:null,scaleInit:function(i){if(this.scaleObj===null){this.scaleObj=new d(this.id,i,this.canvas);t.addCustomEvent(this.scaleObj,"onScaleApply",t.proxy(this.scaleApply,this));t.addCustomEvent(this.scaleObj,"onScaleRestore",t.proxy(this.scaleRestore,this));t.addCustomEvent(this.scaleObj,"onScaleSuggest",t.proxy(this.scaleSuggest,this));t.addCustomEvent(this,"onSetCanvas",t.proxy((function(){this.scaleObj.restore()}),this))}return true},scale:function(i){if(this.scaleInit(t.proxy_context)){this.scaleObj.start(i,this.canvas)}},scaleWidth:function(t,i,e){if(this.scaleInit(e)){this.scaleObj.scaleWidth(t,this.canvas,i)}},scaleHeight:function(t,i,e){if(this.scaleInit(e)){this.scaleObj.scaleHeight(t,this.canvas,i)}},scaleApply:function(i){this.stack.add(this.getCopyCanvas());t.show(this.scaleObj.getPreventer());var e=this.getWorkCanvas(false),s={maxVisibleScale:this.canvas.maxVisibleScale,scale:this.canvas.scale,width:this.canvas.width,height:this.canvas.height,"~shiftX":this.canvas.pos["~shiftX"],"~shiftY":this.canvas.pos["~shiftY"]};t.adjust(e,{props:{width:i.width,height:i.height}});e.getContext("2d").drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,i.width,i.height);this.set(e,{props:{width:i.width,height:i.height}});this.cursor.x=0;this.cursor.y=0;if(this.scaleZoom!==false){var a=(i.width-s.width)*s.scale,o=(i.height-s.height)*s.scale,h=Math.max(-1*s["~shiftX"]+a/2,0),n=Math.max(-1*s["~shiftY"]+o/2,0);this.canvas.pos["~shiftX"]=-1*h/s.scale*this.canvas.scale;this.canvas.pos["~shiftY"]=-1*n/s.scale*this.canvas.scale;t.addClass(this.canvasBlock,"adm-photoeditor-active-image-ascetic");this.zoomProcess(s.scale);t.removeClass(this.canvasBlock,"adm-photoeditor-active-image-ascetic")}if(this.cropObj){this.cropObj.scale()}t.hide(this.scaleObj.getPreventer());this.changed=true},scaleRestore:function(){t.onCustomEvent(this,"onScaleCanvas",arguments)},scaleSuggest:function(){t.onCustomEvent(this,"onScaleCanvas",arguments)}};var d=function(i,e,s){this.id=i;this.pointer=e;var a=t.pos(this.pointer.parentNode);this.divisionValue=a.height/200;this.process=this.process.bind(this);this.finish=this.finish.bind(this);if(s){this.init(s)}};d.prototype={canvas:null,divisionValue:0,value:0,minValue:0,maxValue:100,cursor:{start:0,end:0},preventer:null,params:{scaleX:1,scaleY:1,"~scaleX":1,"~scaleY":1},init:function(t){this.canvas=t;this.value=0;this.minValue=(Math.max(1/t.width,1/t.height)-1)*100;this.params.width=this.canvas.width;this.params.height=this.canvas.height;this.params["~scaleX"]=1;this.params["~scaleY"]=1;return this.block},getPreventer:function(){var i=null;if(this.preventer===null){i=t.create("DIV",{attrs:{className:"adm-photoeditor-scale-area"}});if(t(this.canvas)){this.canvas.parentNode.parentNode.insertBefore(i,this.canvas.parentNode);this.preventer=i}}return this.preventer},start:function(i,e){this.init(e);t.fixEventPageY(i);this.cursor.start=i.pageY;t.bind(document,"mousemove",this.process);t.bind(document,"mouseup",this.finish);return t.PreventDefault(i)},process:function(i){t.fixEventPageY(i);this.cursor.end=i.pageY;this.value=(this.cursor.start-this.cursor.end)/this.divisionValue;if(this.value>this.maxValue)this.value=this.maxValue;else if(this.value<this.minValue)this.value=this.minValue;this.setVis();return t.PreventDefault(i)},finish:function(i){t.unbind(document,"mousemove",this.process);t.unbind(document,"mouseup",this.finish);if(parseInt(this.value)!==0){this.change()}else{this.restore()}return t.PreventDefault(i)},setVis:function(){this.pointer.style.top=50+parseInt(-1*this.value*.5)+"%";this.pointer.innerHTML=Math.ceil(this.value)+"%";this.params.scaleX=(1+this.value/100)*this.params["~scaleX"];this.params.scaleY=(1+this.value/100)*this.params["~scaleY"];this.params.width=Math.ceil(this.canvas.width*this.params.scaleX);this.params.height=Math.ceil(this.canvas.height*this.params.scaleY);this.canvas.style.transform="scale("+this.params.scaleX+", "+this.params.scaleY+")";t.onCustomEvent(this,"onScaleSuggest",[this.params,this.value])},scaleWidth:function(t,i,e){t=Math.ceil(t);if(t<=0)return;this.init(i);var s=this.params["~scaleX"];this.params["~scaleX"]=t/this.params.width;s=this.params["~scaleX"]-s;if(e){this.params["~scaleY"]+=s}this.setVis();this.change()},scaleHeight:function(t,i,e){t=Math.ceil(t);if(t<=0)return;this.init(i);var s=this.params["~scaleX"];this.params["~scaleY"]=t/this.params.height;s=this.params["~scaleY"]-s;if(e){this.params["~scaleX"]+=s}this.setVis();this.change()},change:function(){t.onCustomEvent(this,"onScaleApply",[this.params,this.value])},restore:function(){this.value=0;this.params["~scaleX"]=1;this.params["~scaleY"]=1;this.setVis();this.canvas.style.transform="";t.onCustomEvent(this,"onScaleRestore",[this.canvas])}};var c=function(t,i,e){this.id=t;this.canvas=i;this.block=e};c.prototype={active:false,canvas:null,root:null,preventer:null,projection:null,pointer:null,block:null,turn:function(){if(this.init()){if(this.active===false){this.start()}else{this.finish()}}},cursor:{pageX:0,pageY:0},cropParams:{width:0,height:0,top:0,left:0,topShift:0,leftShift:0,defaultWidth:0,defaultHeight:0},init:function(){if(this.preventer===null){this.root=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-area-root"},style:{position:"absolute",boxSizing:"border-box","-webkit-user-select":"none"}});document.body.appendChild(this.root);t.ZIndexManager.register(this.root);this.preventer=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-area"}});this.apply=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-apply"},style:{zIndex:3},events:{click:this.cropApply.bind(this)}});this.cancel=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-cancel"},style:{zIndex:3},events:{click:this.cropCancel.bind(this)}});this.proportion=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-proportion"},style:{zIndex:3},events:{click:this.cropProportionActivate.bind(this)}});this.width=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-width"}});this.height=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-height"}});this.stretchStart=this.stretchStart.bind(this);this.stretch=this.stretch.bind(this);this.stretchEnd=this.stretchEnd.bind(this);this.leftBottom=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-left-bottom"},events:{mousedown:this.stretchStart}});this.left=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-left"},events:{mousedown:this.stretchStart}});this.leftTop=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-left-top"},events:{mousedown:this.stretchStart}});this.top=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-top"},events:{mousedown:this.stretchStart}});this.rightTop=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-right-top"},events:{mousedown:this.stretchStart}});this.right=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-right"},events:{mousedown:this.stretchStart}});this.rightBottom=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-right-bottom"},events:{mousedown:this.stretchStart}});this.bottom=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-bottom"},events:{mousedown:this.stretchStart}});this.pointer=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-pointer"},style:{position:"absolute",top:0,left:0,bottom:0,right:0,boxSizing:"border-box",zIndex:3,cursor:"pointer"},children:[this.apply,this.cancel,this.proportion,t.create("DIV",{attrs:{className:"adm-photoeditor-crop-measures"},children:[this.width,this.height]}),this.leftBottom,this.left,this.leftTop,this.top,this.rightTop,this.right,this.rightBottom,this.bottom]});this.overlayTop=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-overlay-top"}});this.overlayRight=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-overlay-right"}});this.overlayBottom=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-overlay-bottom"}});this.overlayLeft=t.create("DIV",{attrs:{className:"adm-photoeditor-crop-overlay-left"}});this.projection=t.create("DIV",{attrs:{id:"projection"},style:{position:"absolute",top:0,left:0,bottom:0,right:0,zIndex:1001,display:"none",boxSizing:"border-box"},children:[this.overlayTop,this.overlayRight,this.overlayBottom,this.overlayLeft,this.pointer]});this.projection.appendChild(this.pointer);this.root.appendChild(this.projection);this.root.appendChild(this.preventer);this.drawStart=this.drawStart.bind(this);this.draw=this.draw.bind(this);this.drawEnd=this.drawEnd.bind(this);this.stop=this.stop.bind(this);this.moveStart=this.moveStart.bind(this);this.move=this.move.bind(this);this.moveEnd=this.moveEnd.bind(this);t.bind(this.pointer,"mousedown",this.moveStart)}return this.block},scale:function(){if(this.canvas.width<this.cropParams.width||this.canvas.height<this.cropParams.height){this.finish()}else if(this.active===true){var t=0,i=0,e=0,s=0;if(this.projection){t=Math.ceil(parseInt(this.projection.style.left?this.projection.style.left.replace("px",""):0));e=Math.ceil(parseInt(this.projection.style.top?this.projection.style.top.replace("px",""):0))}this.showProjection();if(this.projection){i=Math.ceil(this.projection.style.left?parseInt(this.projection.style.left.replace("px","")):0);s=Math.ceil(this.projection.style.top?parseInt(this.projection.style.top.replace("px","")):0);if(t!=i)this.pointer.left=Math.max(0,this.pointer.left+t-i);if(s!=e)this.pointer.top=Math.max(0,this.pointer.top+e-s)}this.cropParams.left=Math.ceil(this.pointer.left/this.canvas.scale+this.canvas.visiblePart.left);this.cropParams.top=Math.ceil(this.pointer.top/this.canvas.scale+this.canvas.visiblePart.top);if(this.canvas.scale<1){this.cropParams.width=Math.ceil(this.pointer.width/this.canvas.scale);this.cropParams.height=Math.ceil(this.pointer.height/this.canvas.scale)}else{this.pointer.width=Math.ceil(this.cropParams.width*this.canvas.scale);this.pointer.height=Math.ceil(this.cropParams.height*this.canvas.scale)}this.setLeft(this.pointer.left,this.cropParams.left);this.setTop(this.pointer.top,this.cropParams.top);this.setWidth(this.pointer.width,this.cropParams.width);this.setHeight(this.pointer.height,this.cropParams.height)}},drawStart:function(i){var e=0,s=0;if(i){t.fixEventPageXY(i);e=i.pageX-this.projection.pos.left;s=i.pageY-this.projection.pos.top;if(e>this.projection.pos.width||s>this.projection.pos.height)return this.finish();this.cursor={pageX:i.pageX,pageY:i.pageY};t.PreventDefault(i)}e=e>0?e:0;s=s>0?s:0;this.cropParams.left=Math.ceil(e/this.canvas.scale+this.canvas.visiblePart.left);this.cropParams.top=Math.ceil(s/this.canvas.scale+this.canvas.visiblePart.top);this.cropParams.maxWidth=this.canvas.width-this.cropParams.left;this.cropParams.maxHeight=this.canvas.height-this.cropParams.top;this.cropParams.savePropotions=this.proportion.active===true;this.setLeft(e,this.cropParams.left);this.setWidth(0,0);this.setTop(s,this.cropParams.top);this.setHeight(0,0);this.showPointer();t.bind(document,"mousemove",this.draw);return false},draw:function(i){var e=0,s=0;if(i){t.fixEventPageXY(i);e=i.pageX-this.cursor.pageX;s=i.pageY-this.cursor.pageY;t.PreventDefault(i)}this.cropParams.width=Math.ceil(e/this.canvas.scale);if(e<=0){e=0;this.cropParams.width=0}else if(e>=this.projection.pos.width-this.pointer.left){e=this.projection.pos.width-this.pointer.left;this.cropParams.width=this.cropParams.maxWidth}this.setWidth(e,this.cropParams.width);this.cropParams.height=Math.ceil(s/this.canvas.scale);if(s<=0){s=0;this.cropParams.height=0}else if(s>=this.projection.pos.height-this.pointer.top){s=this.projection.pos.height-this.pointer.top;this.cropParams.height=this.cropParams.maxHeight}this.setHeight(s,this.cropParams.height);return false},drawEnd:function(i){if(i)t.PreventDefault(i);this.stop();return false},insert:function(i,e){if(!this.init()){t.DoNothing()}else if(this.canvas.width<i||this.canvas.height<e){t.onCustomEvent(this,"onCropTooBig",[i,e])}else{this.start();this.cropProportionActivate(true);t.onCustomEvent(this,"onCropStart",[]);this.drawStart();this.cropParams.width=i;i=Math.ceil(i*this.canvas.scale);if(i<=0){i=0;this.cropParams.width=0}else if(i>=this.projection.pos.width-this.pointer.left){i=this.projection.pos.width-this.pointer.left;this.cropParams.width=this.cropParams.maxWidth}this.setWidth(i,this.cropParams.width);this.cropParams.height=e;e=Math.ceil(e*this.canvas.scale);if(e<=0){e=0;this.cropParams.height=0}else if(e>=this.projection.pos.height-this.pointer.top){e=this.projection.pos.height-this.pointer.top;this.cropParams.height=this.cropParams.maxHeight}this.setHeight(e,this.cropParams.height);this.drawEnd()}},moveStart:function(i){this.cursor=null;if(i.target==this.pointer){t.fixEventPageXY(i);this.showPreventer();this.cursor={pageX:i.pageX,pageY:i.pageY,x:i.pageX-this.projection.pos.left-this.pointer.left,y:i.pageY-this.projection.pos.top-this.pointer.top};t.bind(document,"mousemove",this.move);t.bind(document,"mouseup",this.moveEnd)}},move:function(i){if(this.cursor!=null){t.fixEventPageXY(i);var e=i.pageX-this.cursor.pageX,s=i.pageY-this.cursor.pageY,a=this.pointer.left+e,o=this.pointer.top+s;this.cursor.pageX=i.pageX;this.cursor.pageY=i.pageY;if(a+this.pointer.width>=this.projection.pos.width&&this.canvas.visiblePart.left+this.canvas.visiblePart.width>=this.canvas.width){a=this.projection.pos.width-this.pointer.width;this.cropParams.left=this.canvas.width-this.cropParams.width}else{if(a<=0)a=0;else if(a+this.pointer.width>=this.projection.pos.width)a=this.projection.pos.width-this.pointer.width;this.cropParams.left=Math.ceil(a/this.canvas.scale+this.canvas.visiblePart.left)}if(o+this.pointer.height>=this.projection.pos.height&&this.canvas.visiblePart.top+this.canvas.visiblePart.height>=this.canvas.height){o=this.projection.pos.height-this.pointer.height;this.cropParams.top=this.canvas.height-this.cropParams.height}else{if(o<=0)o=0;else if(o+this.pointer.height>=this.projection.pos.height)o=this.projection.pos.height-this.pointer.height;this.cropParams.top=Math.ceil(o/this.canvas.scale+this.canvas.visiblePart.top)}this.setLeft(a,this.cropParams.left);this.setTop(o,this.cropParams.top)}},moveEnd:function(){this.hidePreventer();t.unbind(document,"mousemove",this.move);t.unbind(document,"mouseup",this.moveEnd)},showPointer:function(){this.block.style.display="block";this.pointer.style.display="block";this.overlayTop.style.display="block";this.overlayRight.style.display="block";this.overlayBottom.style.display="block";this.overlayLeft.style.display="block"},hidePointer:function(){this.block.style.top=0;this.block.style.bottom=0;this.block.style.width=0;this.block.style.height=0;this.block.style.display="none";this.pointer.style.display="none";this.overlayTop.style.display="none";this.overlayRight.style.display="none";this.overlayBottom.style.display="none";this.overlayLeft.style.display="none"},showProjection:function(){var i=t.pos(this.block.parentNode.parentNode,false);t.adjust(this.root,{style:{left:i.left+"px",top:i.top+"px",width:i.width+"px",height:i.height+"px",display:"block"}});t.ZIndexManager.bringToFront(this.root);var e={left:0,top:0,right:0,bottom:0,display:"block"};if(this.canvas.visiblePart.topGap>0)e.top=Math.ceil(this.canvas.visiblePart.topGap)+"px";if(this.canvas.visiblePart.leftGap>0)e.left=Math.ceil(this.canvas.visiblePart.leftGap)+"px";if(this.canvas.visiblePart.bottomGap>0)e.bottom=Math.ceil(this.canvas.visiblePart.bottomGap)+"px";if(this.canvas.visiblePart.rightGap>0)e.right=Math.ceil(this.canvas.visiblePart.rightGap)+"px";t.adjust(this.projection,{style:e});this.projection.pos=t.pos(this.projection)},hideProjection:function(){t.hide(this.root);t.hide(this.projection);t.hide(this.preventer)},showPreventer:function(){t.show(this.preventer)},hidePreventer:function(){t.hide(this.preventer)},start:function(){this.active=true;t.bind(document,"mousedown",this.drawStart);t.bind(document,"mouseup",this.drawEnd);this.hidePointer();this.showProjection();this.showPreventer();t.onCustomEvent(this,"onCropStart",[])},stop:function(){this.hidePreventer();t.unbind(document,"mousedown",this.drawStart);t.unbind(document,"mousemove",this.draw);t.unbind(document,"mouseup",this.drawEnd);t.onCustomEvent(this,"onCropStop",[])},finish:function(){this.active=false;this.stop();this.hidePointer();this.hideProjection();t.onCustomEvent(this,"onCropFinish",[this.cropParams])},cropApply:function(){this.finish();if(this.cropParams.width>0&&this.cropParams.height>0){t.onCustomEvent(this,"onCropApply",[this.cropParams])}},cropCancel:function(){t.onCustomEvent(this,"onCropCancel",[]);this.finish()},cropProportion:{active:false,"w/h":0,"h/w":0},cropProportionActivate:function(i){if(!(i===true||i===false)){i=this.cropProportion.active!==true}this.cropProportion.active=i;if(this.cropProportion.active){if(!t.hasClass(this.proportion,"active")){t.addClass(this.proportion,"active")}t.hide(this.left);t.hide(this.top);t.hide(this.right);t.hide(this.bottom)}else{t.removeClass(this.proportion,"active");t.show(this.left);t.show(this.top);t.show(this.right);t.show(this.bottom)}},cropProportionInit:function(){if(this.cropProportion.active!==true){this.cropProportion["w/h"]=0;this.cropProportion["h/w"]=0}else if(this.pointer.width>0&&this.pointer.height>0){this.cropProportion["w/h"]=this.pointer.width/this.pointer.height;this.cropProportion["h/w"]=this.pointer.height/this.pointer.width}else{this.cropProportion["w/h"]=1;this.cropProportion["h/w"]=1}},stretchPosition:null,stretchStart:function(i){t.PreventDefault(i);var e=i["currentTarget"]||i["target"];this.stretchPosition=e.className.replace("adm-photoeditor-crop-","");this.cursor=null;if(this.stretchPosition=="left-bottom"||this.stretchPosition=="left"||this.stretchPosition=="left-top"||this.stretchPosition=="top"||this.stretchPosition=="right-top"||this.stretchPosition=="right"||this.stretchPosition=="right-bottom"||this.stretchPosition=="bottom"){t.fixEventPageXY(i);this.cropProportionInit();this.showPreventer();this.cursor={pageX:i.pageX,pageY:i.pageY,left:this.projection.pos.left+this.pointer.left,right:this.projection.pos.left+this.pointer.left+this.pointer.width,top:this.projection.pos.top+this.pointer.top,bottom:this.projection.pos.top+this.pointer.top+this.pointer.height};t.bind(document,"mousemove",this.stretch);t.bind(document,"mouseup",this.stretchEnd)}return false},stretch:function(i){if(this.cursor!=null){t.fixEventPageXY(i);var e,s=null,a=null,o=null,h=null;this.cursor.pageX=i.pageX;this.cursor.pageY=i.pageY;if(this.stretchPosition.indexOf("left")>=0){e=this.pointer.left+this.pointer.width;a=Math.max(this.cursor.right-i.pageX,0);a=Math.min(a,e);s=e-a}else if(this.stretchPosition.indexOf("right")>=0){a=Math.max(i.pageX-this.cursor.left,0)}if(a!==null){s=s===null?this.pointer.left:s;if(a<=0){a=0}else if(a>=this.projection.pos.width-s){a=this.projection.pos.width-s}}if(this.stretchPosition.indexOf("top")>=0){e=this.pointer.top+this.pointer.height;h=Math.max(this.cursor.bottom-i.pageY,0);h=Math.min(h,e);o=e-h}else if(this.stretchPosition.indexOf("bottom")>=0){h=Math.max(i.pageY-this.cursor.top,0)}if(h!==null){o=o===null?this.pointer.top:o;if(h<=0){h=0}else if(h>=this.projection.pos.height-o){h=this.projection.pos.height-o}}var n=false;if(this.cropProportion.active===true){if(a&&h){var r;if(this.cropProportion["h/w"]*a>h){r=a;a=this.cropProportion["w/h"]*h;if(this.stretchPosition.indexOf("left")>=0){s+=r-a}}else{r=h;h=this.cropProportion["h/w"]*a;if(this.stretchPosition.indexOf("top")>=0){o+=r-h}}if(this.cropProportion["h/w"]==1){this.cropParams.left=Math.ceil(s/this.canvas.scale+this.canvas.visiblePart.left);this.cropParams.top=Math.ceil(o/this.canvas.scale+this.canvas.visiblePart.top);n=Math.min(this.canvas.width-this.cropParams.left,this.canvas.height-this.cropParams.top)}}else{a=null;h=null}}if(a!==null){this.cropParams.left=Math.ceil(s/this.canvas.scale+this.canvas.visiblePart.left);this.cropParams.maxWidth=n||this.canvas.width-this.cropParams.left;this.cropParams.width=Math.ceil(a/this.canvas.scale);if(a<=0){this.cropParams.width=0}else if(this.cropParams.width>=this.cropParams.maxWidth){this.cropParams.width=this.cropParams.maxWidth}this.setLeft(s,this.cropParams.left);this.setWidth(a,this.cropParams.width)}if(h!==null){this.cropParams.top=Math.ceil(o/this.canvas.scale+this.canvas.visiblePart.top);this.cropParams.maxHeight=n||this.canvas.height-this.cropParams.top;this.cropParams.height=Math.ceil(h/this.canvas.scale);if(h<=0){this.cropParams.height=0}else if(this.cropParams.height>=this.cropParams.maxHeight){this.cropParams.height=this.cropParams.maxHeight}this.setTop(o,this.cropParams.top);this.setHeight(h,this.cropParams.height)}}},stretchEnd:function(){this.hidePreventer();t.unbind(document,"mousemove",this.stretch);t.unbind(document,"mouseup",this.stretchEnd)},setWidth:function(t,i){this.pointer.width=t;this.pointer.style.width=t+"px";this.block.width=this.width.innerHTML=i;this.block.style.width=i+"px";this.overlayTop.style.width=this.pointer.left+this.pointer.width+"px";this.overlayRight.style.left=this.pointer.left+this.pointer.width+"px"},setLeft:function(t,i){this.pointer.style.left=t+"px";this.pointer.left=t;this.block.style.left=i+"px";this.overlayTop.style.width=this.pointer.left+this.pointer.width+"px";this.overlayRight.style.left=this.pointer.left+this.pointer.width+"px";this.overlayBottom.style.left=this.pointer.left+"px";this.overlayLeft.style.width=this.pointer.left+"px"},setHeight:function(t,i){this.pointer.height=t;this.pointer.style.height=t+"px";this.block.height=this.height.innerHTML=i;this.block.style.height=i+"px";this.overlayRight.style.height=this.pointer.top+t+"px";this.overlayBottom.style.top=this.pointer.top+t+"px"},setTop:function(t,i){this.pointer.style.top=t+"px";this.pointer.top=t;this.block.style.top=i+"px";this.overlayTop.style.height=this.pointer.top+"px";this.overlayRight.style.height=this.pointer.top+this.pointer.height+"px";this.overlayBottom.style.top=this.pointer.top+this.pointer.height+"px";this.overlayLeft.style.top=this.pointer.top+"px"}};var u=function(i,e){this.block=i;this.id=this.block.id+"Map";if(t(this.id+"Root")){this.root=t(this.id+"Root")}else{this.root=t.create("DIV",{style:{display:"none",position:"absolute"},attrs:{id:this.id+"Root",className:"adm-photoeditor-active-map-root"},html:['<div class="adm-photoeditor-active-map-block" id="',this.id,'Block"> \t\t\t\t\t<div class="adm-photoeditor-active-map"> \t\t\t\t\t\t<div class="adm-photoeditor-active-map-image"> \t\t\t\t\t\t\t<canvas id="',this.id,'Canvas"></canvas> \t\t\t\t\t\t</div> \t\t\t\t\t\t<div class="adm-photoeditor-active-map-area"></div> \t\t\t\t\t\t<div class="adm-photoeditor-active-map-pointer"></div> \t\t\t\t\t</div> \t\t\t\t\t<div class="adm-photoeditor-active-map-handle" id="',this.id,'Resizer"> \t\t\t\t</div> \t\t\t\t</div>'].join("").replace(/[\n\t]/gi,"").replace(/>\s</gi,"><")});document.body.appendChild(this.root);t.ZIndexManager.register(this.root)}this.moveStart=this.moveStart.bind(this);this.move=this.move.bind(this);this.moveEnd=this.moveEnd.bind(this);this._bindNodes=this.bindNodes.bind(this);t.defer_proxy(this._bindNodes)(e);t.bind(window,"resize",t.proxy(this.onResizeWindow,this));return this};u.prototype={bindNodesCounter:0,bindNodes:function(i){this.bindNodesCounter++;if(this.bindNodesCounter>100||!t(this.id+"Canvas")){if(this.bindNodesCounter<=100)t.defer_proxy(this._bindNodes)(i);return}this.canvasMapBlock=t(this.id+"Block");this.canvasMapResizer=t(this.id+"Resizer");t.hide(this.canvasMapResizer);this.canvasMapCover=this.canvasMapBlock.firstChild;this.canvasMap=t(this.id+"Canvas");this.canvasMapPointer=this.canvasMapBlock.firstChild.childNodes[2];this.canvasMapPointer.params=i;t.addClass(this.canvasMapPointer,"adm-photoeditor-active-map-pointer-draggable");t.bind(this.canvasMapPointer,"mousedown",this.moveStart);t.bind(this.canvasMapResizer,"mousedown",this.stretchStart);t.onCustomEvent(this,"onMapIsInitialised",[this])},init:function(i,e){if(e){var s=t.UploaderUtils.scaleImage(e,this.canvasMapPointer.params);this.root.style.display="none";this.collapsedNode.style.display="none";t.adjust(this.canvasMap,{props:s.destin});this.canvasMap.pos=null;this.options.visible=false;t.adjust(this.canvasMapCover,{style:{width:s.destin.width+"px",height:s.destin.height+"px"}});t.adjust(this.canvasMapPointer,{props:{width:s.destin.width,height:s.destin.height},style:{width:s.destin.width+"px",height:s.destin.height+"px"}});this.canvasMap.canvasProp=s.coeff}this.canvasMap.canvasWidth=i.width;this.canvasMap.canvasHeight=i.height;this.canvasMap.getContext("2d").drawImage(i,0,0,i.width,i.height,0,0,this.canvasMap.width,this.canvasMap.height)},options:{collapsed:false,collapsing:null,visible:false,busy:false,mode:"slow"},animationV:null,animationC:null,show:function(){if(this.options.visible)return;else if(this.animationV)this.animationV.stop();this.options.visible=true;var i=t.pos(this.block,false);this.root.pos={top:i.top,left:i.right-this.canvasMap.width,width:this.canvasMap.width,height:this.canvasMap.height};this.root.style.top=this.root.pos.top+"px";this.root.style.left=this.root.pos.left+"px";this.root.style.overflow="hidden";this.root.style.width=this.root.pos.width+"px";this.root.style.height=this.root.pos.height+"px";this.root.style.display=this.options.collapsed?"none":"block";this.collapsedNode.style.display="";t.ZIndexManager.bringToFront(this.root);this.canvasMapBlock.style.top="-"+(this.canvasMap.height+1)+"px";this.canvasMapBlock.style.left=0;this.canvasMapBlock.style.width=this.canvasMap.width+"px";this.canvasMapBlock.style.height=this.canvasMap.height+"px";this.canvasMapBlock.y=this.canvasMapBlock.y||this.canvasMap.height;this.canvasMapBlock.x=this.canvasMapBlock.x||this.canvasMap.width;this.animationV=new t.easing({duration:200,start:{y:this.canvasMapBlock.y,x:this.canvasMapBlock.x},finish:{y:0,x:0},step:t.delegate((function(t){this.canvasMapBlock.y=t.y;this.canvasMapBlock.style.top="-"+t.y+"px"}),this),complete:t.delegate((function(){this.canvasMapBlock.y=false;this.canvasMapBlock.x=false;this.canvasMapBlock.style.top=0;this.canvasMapBlock.style.left=0;this.root.style.overflow="visible";this.animationV=null}),this)});this.animationV.animate()},hide:function(i){var e=t.delegate((function(){this.root.style.display="none";this.collapsedNode.style.display="none";delete this.root.pos;this.canvasMapBlock.y=false;this.canvasMapBlock.x=false;this.animationV=null}),this);if(i!==true){if(this.animationV)this.animationV.stop();this.options.visible=false;e()}else if(this.options.visible){if(this.animationV)this.animationV.stop();this.options.visible=false;this.root.style.overflow="hidden";this.canvasMapBlock.y=this.canvasMapBlock.y||0;this.canvasMapBlock.x=this.canvasMapBlock.x||0;this.animationV=new t.easing({duration:200,start:{y:this.canvasMapBlock.y,x:this.canvasMapBlock.x},finish:{y:this.canvasMap.height,x:this.canvasMap.width},step:t.delegate((function(t){this.canvasMapBlock.y=t.y;this.canvasMapBlock.style.top="-"+t.y+"px";this.canvasMapBlock.x=t.x}),this),complete:e});this.animationV.animate()}else{e()}},zoom:function(i){var e=i&&(i["~top"]>0||i["~left"]>0||i["~width"]<this.canvasMap.canvasWidth||i["~height"]<this.canvasMap.canvasHeight);if(e){var s=Math.ceil(i["~left"]*this.canvasMap.canvasProp),a=Math.ceil(i["~top"]*this.canvasMap.canvasProp),o=Math.min(Math.ceil(i["~width"]*this.canvasMap.canvasProp),this.canvasMap.width-s),h=Math.min(Math.ceil(i["~height"]*this.canvasMap.canvasProp),this.canvasMap.height-a);t.adjust(this.canvasMapPointer,{props:{etalonWidth:Math.ceil(i["~etalonWidth"]*this.canvasMap.canvasProp),etalonHeight:Math.ceil(i["~etalonHeight"]*this.canvasMap.canvasProp),"bx-left":s,"bx-top":a,width:o,height:h},style:{width:o+"px",height:h+"px",transform:"translate3d("+s+"px, "+a+"px, 0)"}})}else{t.adjust(this.canvasMapPointer,{props:{etalonWidth:this.canvasMap.width,etalonHeight:this.canvasMap.height,"bx-left":0,"bx-top":0,width:this.canvasMap.width,height:this.canvasMap.height},style:{width:this.canvasMap.width+"px",height:this.canvasMap.height+"px",transform:"translate3d(0, 0, 0)"}})}},shiftX:0,shiftY:0,moveEventTimeout:0,moveEventParams:{top:0,left:0},moveCursor:null,wSize:null,moveStart:function(i){this.moveCursor=null;if(i.target==this.canvasMapPointer){if(this.canvasMap.pos===null)this.canvasMap.pos=t.pos(this.canvasMap);this.wSize=t.GetWindowSize();this.moveCursor={deltaX:this.canvasMap.pos["left"]+(this.canvasMapPointer["bx-left"]||0),deltaY:this.canvasMap.pos["top"]+(this.canvasMapPointer["bx-top"]||0)};this.moveCursor.x=i.clientX+this.wSize.scrollLeft-this.moveCursor.deltaX;this.moveCursor.y=i.clientY+this.wSize.scrollTop-this.moveCursor.deltaY;t.bind(document,"mousemove",this.move);t.bind(document,"mouseup",this.moveEnd)}},move:function(i){if(this.moveCursor===null)return;var e=i.clientX+this.wSize.scrollLeft,s=i.clientY+this.wSize.scrollTop,a=parseInt(this.canvasMapPointer.etalonWidth),o=parseInt(this.canvasMapPointer.etalonHeight),h=false,n=false;e-=this.canvasMap.pos["left"]+this.moveCursor.x;if(e<=0)e=0;else if(e>this.canvasMap.width-this.canvasMapPointer.width){e=this.canvasMap.width-this.canvasMapPointer.width;h=true}s-=this.canvasMap.pos["top"]+this.moveCursor.y;if(s<=0)s=0;else if(s>this.canvasMap.height-this.canvasMapPointer.height){s=this.canvasMap.height-this.canvasMapPointer.height;n=true}if(e!=this.shiftX||s!=this.shiftY){this.shiftX=e;this.shiftY=s;if(a>this.canvasMapPointer.width&&a+e>this.canvasMap.width)a=this.canvasMap.width-e;if(o>this.canvasMapPointer.height&&o+s>this.canvasMap.height)o=this.canvasMap.height-s;t.adjust(this.canvasMapPointer,{props:{"bx-left":e,"bx-top":s,width:a,height:o},style:{width:a+"px",height:o+"px",transform:"translate3d("+e+"px, "+s+"px, 0)"}});clearTimeout(this.moveEventTimeout);this.moveEventParams={"%left":e/this.canvasMap.width,"%top":s/this.canvasMap.height,left:e/this.canvasMap.canvasProp,top:s/this.canvasMap.canvasProp,right:h,bottom:n,width:a/this.canvasMap.canvasProp,height:o/this.canvasMap.canvasProp};if(!this["moveEventFunction"])this["moveEventFunction"]=t.delegate((function(){t.onCustomEvent(this,"onMapPointerIsMoved",[this.moveEventParams])}),this);this.moveEventTimeout=setTimeout(this.moveEventFunction,100)}},moveEnd:function(){t.unbind(document,"mousemove",this.move);t.unbind(document,"mouseup",this.moveEnd)},collapsedNode:null,registerCollapsedNode:function(i){if(t(i)){this.collapsedNode=t(i);t.bind(this.collapsedNode,"click",t.delegate((function(){if(this.options.collapsed===true){this.collapse(false)}else{this.collapse(true)}}),this));t.bind(this.canvasMapBlock,"dblclick",this.collapse.bind(this))}this.collapseEnd()},collapseEnd:function(){if(this.options.collapsed){this.root.style.display="none";if(this.collapsedNode)t.removeClass(this.collapsedNode,"disabled");t.removeClass(this.root,"collapse");t.addClass(this.root,"collapse2")}else{this.root.style.display="block";t.ZIndexManager.bringToFront(this.root);if(this.collapsedNode)t.addClass(this.collapsedNode,"disabled");t.addClass(this.root,"collapse");t.removeClass(this.root,"collapse2")}this.root.style.transform="translate(0, 0) scale(1, 1)";this.root.style.opacity="1";if(this.root["~top"]){this.root.style.top=this.root["~top"];delete this.root["~top"]}this.options.collapsing=null},collapse:function(i){i=i===true||i===false?i:!this.options.collapsed;if(this.options.collapsing!==null||this.options.collapsed==i)return;this.options.collapsing=true;this.options.collapsed=i;var e,s,a,o;if(i){if(!this.collapsedNode||!this.root.pos){this.collapseEnd()}else{e=t.pos(this.collapsedNode,false);s=this.root.pos;a=Math.ceil(e.left+e.width/2-(s.left+s.width/2));o=e.width*.7/s.width;this.root.style.transform="translate("+a+"px, 0) scale("+o+", "+o+")";this.root.style.opacity="0";this.root["~top"]=this.root.style.top;this.root.style.top=e.top+"px";setTimeout(t.proxy(this.collapseEnd,this),700)}}else if(this.root.pos){this.collapseEnd()}},stretchStart:function(){},occupy:function(){this.options.busy=true},release:function(){this.options.busy=false},onResizeWindow:function(){if(this.options.visible){var i=t.pos(this.block,false);this.root.pos.top=i.top;this.root.pos.left=i.left;this.root.style.top=i.top+"px";this.root.style.left=i.right-this.canvasMap.width+"px"}}};var m=new r})();
//# sourceMappingURL=core_fileinput.map.js